git-svn-id: https://spexeah.com:8443/svn/Asuro@372 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/E1000.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/E1000.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/PCI.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/PCI.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/USB.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/USB.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/console.o
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/console.o
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/console.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/console.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/gdt.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/gdt.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/isr.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr.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/isr44.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/isr44.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/terminal.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/terminal.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/tss.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/tss.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
							
								
								
									
										
											BIN
										
									
								
								lib/util.ppu
									
									
									
									
									
								
							
							
						
						
									
										
											BIN
										
									
								
								lib/util.ppu
									
									
									
									
									
								
							
										
											Binary file not shown.
										
									
								
							
										
											Binary file not shown.
										
									
								
							| @@ -71,7 +71,7 @@ end; | ||||
|  | ||||
| procedure init(); | ||||
| begin | ||||
|     console.writestringln('BDA: Loaded.'); | ||||
|     console.outputln('BDA','Loaded.'); | ||||
|     //TO-DO search for important structures like the MCFG or the EBDA. | ||||
| end; | ||||
|  | ||||
|   | ||||
| @@ -42,6 +42,9 @@ procedure writecharln(character : char); | ||||
| procedure writecharex(character : char; attributes : char); | ||||
| procedure writecharlnex(character : char; attributes : char); | ||||
|  | ||||
| procedure Output(identifier : PChar; str : PChar); | ||||
| procedure Outputln(identifier : PChar; str : PChar); | ||||
|  | ||||
| procedure writestring(str: PChar); | ||||
| procedure writestringln(str: PChar); | ||||
| procedure writestringex(str: PChar; attributes : char); | ||||
| @@ -57,6 +60,7 @@ procedure writewordln(i: DWORD); | ||||
| procedure writewordex(i: DWORD; attributes : char); | ||||
| procedure writewordlnex(i: DWORD; attributes : char); | ||||
|  | ||||
| procedure writehexpair(b : uint8); | ||||
| procedure writehex(i: DWORD); | ||||
| procedure writehexln(i: DWORD); | ||||
| procedure writehexex(i : DWORD; attributes : char); | ||||
| @@ -278,6 +282,36 @@ begin | ||||
|      console._safeincrement_x(); | ||||
| end; | ||||
|  | ||||
| procedure writehexpair(b : uint8); | ||||
| var | ||||
|     bn : Array[0..1] of uint8; | ||||
|     i  : uint8; | ||||
|  | ||||
| begin | ||||
|     bn[0]:= b SHR 4; | ||||
|     bn[1]:= b AND $0F; | ||||
|     for i:=0 to 1 do begin | ||||
|         case bn[i] of | ||||
|             0:writestring('0'); | ||||
|             1:writestring('1'); | ||||
|             2:writestring('2'); | ||||
|             3:writestring('3'); | ||||
|             4:writestring('4'); | ||||
|             5:writestring('5'); | ||||
|             6:writestring('6'); | ||||
|             7:writestring('7'); | ||||
|             8:writestring('8'); | ||||
|             9:writestring('9'); | ||||
|             10:writestring('A'); | ||||
|             11:writestring('B'); | ||||
|             12:writestring('C'); | ||||
|             13:writestring('D'); | ||||
|             14:writestring('E'); | ||||
|             15:writestring('F'); | ||||
|         end; | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure writehexex(i : dword; attributes: char); [public, alias: 'console_writehexex']; | ||||
| var | ||||
|    Hex : Array[0..7] of Byte; | ||||
| @@ -340,6 +374,20 @@ begin | ||||
|      writehexlnex(i, Console_Properties.Default_Attribute); | ||||
| end; | ||||
|  | ||||
| procedure Output(identifier : PChar; str : PChar); | ||||
| begin | ||||
|      writestring('['); | ||||
|      writestring(identifier); | ||||
|      writestring('] '); | ||||
|      writestring(str); | ||||
| end; | ||||
|  | ||||
| procedure Outputln(identifier : PChar; str : PChar); | ||||
| begin | ||||
|      Output(identifier, str); | ||||
|      writestringln(' '); | ||||
| end; | ||||
|  | ||||
| procedure writestringex(str: PChar; attributes: char); [public, alias: 'console_writestringex']; | ||||
| var | ||||
|    i : integer; | ||||
|   | ||||
| @@ -62,7 +62,7 @@ end; | ||||
| function load(ptr : void) : boolean; | ||||
| begin | ||||
|     isr33.hook(uint32(@callback)); | ||||
|     console.writestringln('PS/2 KEYBOARD: LOADED.'); | ||||
|     console.outputln('PS/2 KEYBOARD', 'LOADED.'); | ||||
|     load:= true; | ||||
| end; | ||||
|  | ||||
| @@ -71,7 +71,7 @@ var | ||||
|     devid : TDeviceIdentifier; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('PS/2 KEYBOARD: INIT BEGIN.'); | ||||
|     console.outputln('PS/2 KEYBOARD', 'INIT BEGIN.'); | ||||
|     if keyboard_layout[1].key_code = 0 then lang_USA(); | ||||
|     devid.bus:= biUnknown; | ||||
|     devid.id0:= 0; | ||||
| @@ -81,7 +81,7 @@ begin | ||||
|     devid.id4:= 0; | ||||
|     devid.ex:= nil; | ||||
|     drivermanagement.register_driver_ex('PS/2 Keyboard', @devid, @load, true); | ||||
|     console.writestringln('PS/2 KEYBOARD: INIT END.'); | ||||
|     console.outputln('PS/2 KEYBOARD', 'INIT END.'); | ||||
| end; | ||||
| //2A AA | ||||
|  | ||||
|   | ||||
| @@ -107,7 +107,7 @@ end; | ||||
| function load(ptr : void) : boolean; | ||||
| begin | ||||
|     isr44.hook(uint32(@callback)); | ||||
|     console.writestringln('PS/2 MOUSE: LOADED.');   | ||||
|     console.outputln('PS/2 MOUSE', 'LOADED.');   | ||||
|     load:= true; | ||||
| end; | ||||
|  | ||||
| @@ -116,7 +116,7 @@ var | ||||
|     devid : TDeviceIdentifier; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('PS/2 MOUSE: INIT BEGIN.'); | ||||
|     console.outputln('PS/2 MOUSE', 'INIT BEGIN.'); | ||||
|     devid.bus:= biUnknown; | ||||
|     devid.id0:= 0; | ||||
|     devid.id1:= 0; | ||||
| @@ -125,7 +125,7 @@ begin | ||||
|     devid.id4:= 0; | ||||
|     devid.ex:= nil; | ||||
|     drivermanagement.register_driver_ex('PS/2 Mouse', @devid, @load, true); | ||||
|     console.writestringln('PS/2 MOUSE: INIT END.'); | ||||
|     console.outputln('PS/2 MOUSE', 'INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -79,14 +79,14 @@ var | ||||
|     current_bus : uint8; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('PCI: Scanning Bus: 0'); | ||||
|     console.outputln('PCI', 'Scanning Bus: 0'); | ||||
|     scanBus(0); | ||||
|     //while unscanned busses scan busses | ||||
|     current_bus := 1; | ||||
|     while true do begin | ||||
|         if current_bus < bus_count then begin | ||||
|             console.writestringln('PCI: Scanning Bus: '); | ||||
|             console.writeint(bus_count); | ||||
|             console.output('PCI', 'Scanning Bus: '); | ||||
|             console.writeintln(bus_count); | ||||
|             scanBus(current_bus); | ||||
|             current_bus := current_bus + 1; | ||||
|         end else break; | ||||
| @@ -99,7 +99,7 @@ var | ||||
|     DevID : TDeviceIdentifier; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('PCI: INIT BEGIN.'); | ||||
|     console.outputln('PCI','INIT BEGIN.'); | ||||
|     DevID.Bus:= biUnknown; | ||||
|     DevID.id0:= 0; | ||||
|     DevID.id1:= 0; | ||||
| @@ -107,7 +107,7 @@ begin | ||||
|     DevID.id3:= 0; | ||||
|     DevID.ex:= nil; | ||||
|     drivermanagement.register_driver_ex('PCI Driver', @DevID, @load, true); | ||||
|     console.writestringln('PCI: INIT END.'); | ||||
|     console.outputln('PCI', 'INIT END.'); | ||||
| end; | ||||
|  | ||||
| procedure scanBus(bus : uint8); | ||||
| @@ -315,7 +315,7 @@ begin | ||||
|     DevID^.id4:= device.vendor_id; | ||||
|     DevID^.ex:= nil; | ||||
|  | ||||
|     console.writestring('PCI: Found Device: '); | ||||
|     console.output('PCI', 'Found Device: '); | ||||
|     console.writehex(device.header_type); | ||||
|     console.writestring('  '); | ||||
|     console.writehex(device.device_id);         | ||||
|   | ||||
| @@ -50,12 +50,12 @@ var | ||||
|  | ||||
| begin | ||||
|     devices:= PCI.getDeviceInfo($0C, $03, $10, count); | ||||
|     console.writestring('USB-OHCI: Found '); | ||||
|     console.output('USB-OHCI Driver', 'Found '); | ||||
|     console.writeint(count); | ||||
|     console.writestringln(' USB Controller(s).'); | ||||
|     if count > 0 then begin | ||||
|         for i:=0 to count-1 do begin | ||||
|             console.writestring('USB: Controller['); | ||||
|             console.output('USB-OHCI Driver', 'Controller['); | ||||
|             console.writeint(i); | ||||
|             console.writestring(']: '); | ||||
|             console.writehex(devices[i].device_id); | ||||
| @@ -80,12 +80,12 @@ var | ||||
|  | ||||
| begin | ||||
|     devices:= PCI.getDeviceInfo($0C, $03, $00, count); | ||||
|     console.writestring('USB-UHCI: Found '); | ||||
|     console.output('USB-UHCI Driver','Found '); | ||||
|     console.writeint(count); | ||||
|     console.writestringln(' USB Controller(s).'); | ||||
|     if count > 0 then begin | ||||
|         for i:=0 to count-1 do begin | ||||
|             console.writestring('USB: Controller['); | ||||
|             console.output('USB-UHCI Driver','Controller['); | ||||
|             console.writeint(i); | ||||
|             console.writestring(']: '); | ||||
|             console.writehex(devices[i].device_id); | ||||
| @@ -103,7 +103,7 @@ var | ||||
|     UHCI_ID, OHCI_ID : TDeviceIdentifier; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('USB: INIT BEGIN.'); | ||||
|     console.outputln('USB Driver', 'INIT BEGIN.'); | ||||
|      | ||||
|     UHCI_ID.Bus:= biPCI; | ||||
|     UHCI_ID.id0:= idANY; | ||||
| @@ -124,7 +124,7 @@ begin | ||||
|     drivermanagement.register_driver('USB-UHCI Driver', @UHCI_ID, @loadUHCI); | ||||
|     drivermanagement.register_driver('USB-OHCI Driver', @OHCI_ID, @loadOHCI); | ||||
|  | ||||
|     console.writestringln('USB: INIT END.'); | ||||
|     console.outputln('USB Driver', 'INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -7,7 +7,9 @@ uses | ||||
|     strings, | ||||
|     vmemorymanager, | ||||
|     lmemorymanager, | ||||
|     drivermanagement; | ||||
|     drivermanagement, | ||||
|     drivertypes, | ||||
|     util; | ||||
|  | ||||
| const | ||||
|     INTEL_VEND  = $8086; | ||||
| @@ -95,6 +97,9 @@ const | ||||
|     TSTA_LC                 =       (1 SHL 2);    // Late Collision | ||||
|     LSTA_TU                 =       (1 SHL 3);    // Transmit Underrun | ||||
|  | ||||
|     E1000_NUM_RX_DESC       =       32; | ||||
|     E1000_NUM_TX_DESC       =       8; | ||||
|  | ||||
| type | ||||
|     PE1000_rx_desc = ^TE1000_rx_desc; | ||||
|     TE1000_rx_desc = bitpacked record | ||||
| @@ -117,62 +122,203 @@ type | ||||
|         special : uint16; | ||||
|     end; | ||||
|  | ||||
|     TCardType = (ctUnknown, ctE1000, ctI217, ct82577LM); | ||||
|  | ||||
| procedure init(); | ||||
| procedure fire(); | ||||
| function getMACAddress : uint8; | ||||
| function getMACAddress : puint8; | ||||
| function sendPacket(p_data : void; p_len : uint16) : sint32; | ||||
|  | ||||
| implementation | ||||
|  | ||||
| var | ||||
|     loaded : boolean; | ||||
|     card_type : TCardType; | ||||
|     bar_type : uint8; | ||||
|     io_base  : uint16; | ||||
|     mem_base : uint64; | ||||
|     eeprom_exists : boolean; | ||||
|     mac : array[0..5] of uint8; | ||||
|     rx_descs : array[0..65535] of TE1000_rx_desc; | ||||
|     tx_descs : array[0..65535] of TE1000_tx_desc; | ||||
|     rx_descs : array[0..E1000_NUM_RX_DESC-1] of PE1000_rx_desc; | ||||
|     tx_descs : array[0..E1000_NUM_TX_DESC-1] of PE1000_tx_desc; | ||||
|     rx_curr  : uint16; | ||||
|     tx_curr  : uint16; | ||||
|  | ||||
| procedure writeCommand(p_address : uint16; p_value : uint32); | ||||
| var | ||||
|     mem : puint32; | ||||
|  | ||||
| begin | ||||
|      | ||||
|     if (bar_type = 0) then begin | ||||
|         mem:= puint32(mem_base + p_address); | ||||
|         mem^:= p_value; | ||||
|     end else begin | ||||
|         outl(io_base + 0, p_address); | ||||
|         outl(io_base + 4, p_address) | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| function readCommand(p_address : uint16) : uint32; | ||||
| var | ||||
|     mem : puint32; | ||||
|  | ||||
| begin | ||||
|      | ||||
|     if (bar_type = 0) then begin | ||||
|         mem:= puint32(mem_base + p_address); | ||||
|         readCommand:= mem^; | ||||
|     end else begin | ||||
|         outl(io_base, p_address); | ||||
|         readCommand:= inl(io_base + 4); | ||||
|     end;     | ||||
| end; | ||||
|  | ||||
| function detectEEPROM() : boolean; | ||||
| begin | ||||
| var | ||||
|     val, i : uint32; | ||||
|  | ||||
| begin | ||||
|     val:= 0; | ||||
|     writeCommand(REG_EEPROM, $1); | ||||
|     for i:=0 to 1000 do begin | ||||
|         if eeprom_exists then break; | ||||
|         val:= readCommand(REG_EEPROM); | ||||
|         if (val and $10) > 0 then eeprom_exists:= true else eeprom_exists:= false; | ||||
|     end; | ||||
|     detectEEPROM:= eeprom_exists; | ||||
| end; | ||||
|  | ||||
| function EEPROMRead( address : uint8 ) : uint32; | ||||
| begin | ||||
| var | ||||
|     data : uint16; | ||||
|     tmp  : uint32; | ||||
|  | ||||
| begin | ||||
|     tmp:= 0; | ||||
|     if (eeprom_exists) then begin | ||||
|         writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 8) ); | ||||
|         while (tmp AND (1 SHL 4)) = 0 do begin | ||||
|             tmp:= readCommand(REG_EEPROM); //Might be wrong? | ||||
|         end; | ||||
|     end else begin | ||||
|         writeCommand( REG_EEPROM, 1 OR (uint32(address) SHL 2) ); | ||||
|         while (tmp AND (1 SHL 1)) = 0 do begin | ||||
|             tmp:= readCommand(REG_EEPROM); //Might be wrong? | ||||
|         end; | ||||
|     end; | ||||
|     data:= uint16( (tmp SHR 16) AND ($FFFF) ); | ||||
|     EEPROMRead:= data; | ||||
| end; | ||||
|  | ||||
| function readMACAddress() : boolean; | ||||
| begin | ||||
| var | ||||
|     temp : uint32; | ||||
|     mem_base_mac_8  : puint8; | ||||
|     mem_base_mac_32 : puint32; | ||||
|     res : boolean; | ||||
|     i   : uint32; | ||||
|  | ||||
| begin | ||||
|     res:= true; | ||||
|     if (eeprom_exists) then begin | ||||
|         temp:= EEPROMRead(0); | ||||
|         mac[0]:= temp AND $FF; | ||||
|         mac[1]:= temp SHR 8; | ||||
|         temp:= EEPROMRead(1); | ||||
|         mac[2]:= temp AND $FF; | ||||
|         mac[3]:= temp SHR 8; | ||||
|         temp:= EEPROMRead(2); | ||||
|         mac[4]:= temp AND $FF; | ||||
|         mac[5]:= temp SHR 8; | ||||
|     end else begin | ||||
|         mem_base_mac_8:= puint8(mem_base + $5400); | ||||
|         mem_base_mac_32:= puint32(mem_base + $5400); | ||||
|         if (mem_base_mac_32[0] <> 0) then begin | ||||
|             for i:=0 to 6 do begin | ||||
|                 mac[i]:= mem_base_mac_8[i]; | ||||
|             end;  | ||||
|         end else begin | ||||
|             res:= false; | ||||
|         end; | ||||
|     end; | ||||
|     readMACAddress:= res; | ||||
| end; | ||||
|  | ||||
| procedure startLink(); | ||||
| begin | ||||
| var | ||||
|     val : uint32; | ||||
|  | ||||
| begin | ||||
|     val:= readCommand(REG_CTRL); | ||||
|     writeCommand(REG_CTRL, val OR ECTRL_SLU); | ||||
| end; | ||||
|  | ||||
| procedure rxinit(); | ||||
| begin | ||||
| var | ||||
|     ptr    : puint8; | ||||
|     outptr : puint8; | ||||
|     descs  : PE1000_rx_desc; | ||||
|     i      : uint32; | ||||
|  | ||||
| begin | ||||
|     ptr:= puint8(kalloc(sizeof(TE1000_rx_desc) * E1000_NUM_RX_DESC + 16)); | ||||
|     descs:= PE1000_rx_desc(ptr); | ||||
|     for i:=0 to E1000_NUM_RX_DESC do begin | ||||
|         rx_descs[i]:= PE1000_rx_desc(uint32(descs + i*16)); | ||||
|         rx_descs[i]^.address:= uint64(kalloc(8192 + 16)); | ||||
|         rx_descs[i]^.status:= 0; | ||||
|     end; | ||||
|      | ||||
|     outptr:= puint8(uint32(ptr) - KERNEL_VIRTUAL_BASE); | ||||
|      | ||||
|     writeCommand(REG_TXDESCLO, uint32(uint64(outptr) SHR 32)); | ||||
|     writeCommand(REG_TXDESCHI, uint32(uint64(outptr) AND $FFFFFFFF)); | ||||
|  | ||||
|     writeCommand(REG_RXDESCLO, uint32(outptr)); | ||||
|     writeCommand(REG_RXDESCHI, 0); | ||||
|  | ||||
|     writeCommand(REG_RXDESCLEN, E1000_NUM_RX_DESC * 16); | ||||
|  | ||||
|     writeCommand(REG_RXDESCHEAD, 0); | ||||
|     writeCommand(REG_RXDESCTAIL, E1000_NUM_RX_DESC-1); | ||||
|     rx_curr:= 0; | ||||
|  | ||||
|     writeCommand(REG_RCTRL, RCTL_EN OR RCTL_SBP OR RCTL_UPE OR RCTL_MPE OR RCTL_LBM_NONE OR RTCL_RDMTS_HALF OR RCTL_BAM OR RCTL_SECRC OR RCTL_BSIZE_2048); | ||||
| end; | ||||
|  | ||||
| procedure txinit(); | ||||
| begin | ||||
| var | ||||
|     ptr    : puint8; | ||||
|     outptr : puint8; | ||||
|     descs  : PE1000_tx_desc; | ||||
|     i      : uint32; | ||||
|  | ||||
| begin | ||||
|     ptr:= puint8(kalloc(sizeof(TE1000_tx_desc) * E1000_NUM_TX_DESC + 16));  | ||||
|     descs:= PE1000_tx_desc(ptr); | ||||
|     for i:=0 to E1000_NUM_TX_DESC do begin | ||||
|         tx_descs[i]:= PE1000_tx_desc(uint32(descs + i*16)); | ||||
|         tx_descs[i]^.address:= 0; | ||||
|         tx_descs[i]^.cmd:= 0; | ||||
|         tx_descs[i]^.status:= TSTA_DD; | ||||
|     end; | ||||
|      | ||||
|     outptr:= puint8(uint32(ptr) - KERNEL_VIRTUAL_BASE); | ||||
|  | ||||
|     writeCommand(REG_TXDESCHI, uint32(uint64(outptr) SHR 32)); | ||||
|     writeCommand(REG_TXDESCLO, uint32(uint64(outptr) AND $FFFFFFFF)); | ||||
|  | ||||
|     writeCommand(REG_TXDESCLEN, E1000_NUM_TX_DESC * 16); | ||||
|  | ||||
|     writeCommand( REG_TXDESCHEAD, 0 ); | ||||
|     writeCommand( REG_TXDESCTAIL, 0 ); | ||||
|     tx_curr:= 0; | ||||
|     writeCommand(REG_TCTRL, TCTL_EN OR TCTL_PSP OR (15 SHL TCTL_CT_SHIFT) OR (64 SHL TCTL_COLD_SHIFT) OR TCTL_RTLC); | ||||
|  | ||||
|     //The following is needed for I217 & 82577LM | ||||
|     if (card_type = ct82577LM) OR (card_type = ctI217) then begin | ||||
|         writeCommand(REG_TCTRL, $3003F0FA); | ||||
|         writeCommand(REG_TIPG, $0060200A); | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure enableInturrupt(); | ||||
| @@ -185,9 +331,88 @@ begin | ||||
|  | ||||
| end; | ||||
|  | ||||
| function load(ptr : void) : boolean; | ||||
| procedure writeCardType(); | ||||
| begin | ||||
|     load:= true; | ||||
|     console.output('E1000 Driver', 'Card Type: '); | ||||
|     case card_type of | ||||
|         ctUnknown:writestringln('Unknown'); | ||||
|         ct82577LM:writestringln('82577LM'); | ||||
|         ctE1000:writestringln('Generic E1000'); | ||||
|         ctI217:writestringln('I217'); | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure writeMACAddress(); | ||||
| var | ||||
|     i : integer; | ||||
|  | ||||
| begin | ||||
|     console.writehexpair(mac[0]); | ||||
|     for i:=1 to 5 do begin | ||||
|         console.writestring(':'); | ||||
|         console.writehexpair(mac[i]); | ||||
|     end; | ||||
|     console.writestringln(' '); | ||||
| end; | ||||
|  | ||||
| function load(ptr : void) : boolean; | ||||
| var | ||||
|     PCI_Info : PPCI_Device; | ||||
| begin | ||||
|     console.outputln('E1000 Driver', 'Load Start.'); | ||||
|  | ||||
|     writeCardType(); | ||||
|  | ||||
|     PCI_Info:= PPCI_Device(ptr); | ||||
|     bar_type:= PCI_Info^.address0 AND $00000001; | ||||
|     io_base:=  PCI_Info^.address0 AND $FFFFFFF0; | ||||
|     mem_base:= PCI_INFO^.address0 AND $FFFFFFFC; | ||||
|  | ||||
|     { !!!!! Dirty way to alloc the pages, needs fixing !!!!! } | ||||
|     kpalloc(io_base); | ||||
|     kpalloc(mem_base); | ||||
|      | ||||
|     eeprom_exists:= false; | ||||
|     detectEEPROM(); | ||||
|     if eeprom_exists then console.outputln('E1000 Driver', 'EEPROM Exists: YES.') else console.outputln('E1000 Driver', 'EEPROM Exists: NO.'); | ||||
|     if not readMACAddress() then begin | ||||
|         console.outputln('E1000 Driver', 'MAC Read Failed.'); | ||||
|         load:= false; | ||||
|         exit; | ||||
|     end; | ||||
|     console.output('E1000 Driver', 'MAC Address: '); | ||||
|     writeMACAddress(); | ||||
|  | ||||
|     startLink(); | ||||
|     load:= true;    | ||||
|     console.outputln('E1000 Driver', 'Load Finish.'); | ||||
| end; | ||||
|  | ||||
| function loadE1000(ptr : void) : boolean; | ||||
| begin | ||||
|     loadE1000:= false; | ||||
|     if not Loaded then begin | ||||
|         card_type:= ctE1000; | ||||
|         loadE1000:= load(ptr); | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| function load82577LM(ptr : void) : boolean; | ||||
| begin | ||||
|     load82577LM:= false; | ||||
|     if not Loaded then begin | ||||
|         card_type:= ct82577LM; | ||||
|         load82577LM:= load(ptr); | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| function loadI217(ptr : void) : boolean; | ||||
| begin | ||||
|     loadI217:= false; | ||||
|     if not Loaded then begin | ||||
|         card_type:= ctI217; | ||||
|         loadI217:= load(ptr); | ||||
|     end; | ||||
| end; | ||||
|  | ||||
| procedure init(); | ||||
| @@ -195,6 +420,7 @@ var | ||||
|     dev : TDeviceIdentifier; | ||||
|  | ||||
| begin | ||||
|     card_type:= ctUnknown; | ||||
|     dev.Bus:= biPCI; | ||||
|     dev.id0:= INTEL_VEND; | ||||
|     dev.id1:= idANY; | ||||
| @@ -202,11 +428,11 @@ begin | ||||
|     dev.id3:= idANY; | ||||
|     dev.id4:= E1000_DEV; | ||||
|     dev.ex:= nil; | ||||
|     drivermanagement.register_driver('E1000 Ethernet Driver', @dev, @load); | ||||
|     drivermanagement.register_driver('E1000 Ethernet Driver', @dev, @loadE1000); | ||||
|     dev.id4:= I217_DEV; | ||||
|     drivermanagement.register_driver('I217 Ethernet Driver', @dev, @load); | ||||
|     drivermanagement.register_driver('I217 Ethernet Driver', @dev, @loadI217); | ||||
|     dev.id4:= LM82577_DEV; | ||||
|     drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load); | ||||
|     drivermanagement.register_driver('82577LM Ethernet Driver', @dev, @load82577LM); | ||||
| end; | ||||
|  | ||||
| procedure fire(); | ||||
| @@ -214,9 +440,9 @@ begin | ||||
|  | ||||
| end; | ||||
|  | ||||
| function getMACAddress : uint8; | ||||
| function getMACAddress : puint8; | ||||
| begin | ||||
|  | ||||
|     getMACAddress:= puint8(@mac[0]); | ||||
| end;  | ||||
|  | ||||
| function sendPacket(p_data : void; p_len : uint16) : sint32; | ||||
|   | ||||
| @@ -11,7 +11,7 @@ implementation | ||||
|  | ||||
| function load(ptr : void) : boolean; | ||||
| begin | ||||
|     console.writestringln('DUMMY DRIVER LOADED.') | ||||
|     console.outputln('DUMMY DRIVER', 'LOADED.') | ||||
| end; | ||||
|  | ||||
| procedure init; | ||||
|   | ||||
| @@ -307,7 +307,12 @@ begin | ||||
|         end; | ||||
|         RegList^.Next:= NewReg; | ||||
|     end; | ||||
|     console.output('Driver Management', 'New Driver Registered: '); | ||||
|     console.writestringln(NewReg^.Driver_Name); | ||||
|     if force_load then begin | ||||
|         console.output('Driver Management', 'Driver ('); | ||||
|         console.writestring(NewReg^.Driver_Name); | ||||
|         console.writestringln(') forced to load.'); | ||||
|         NewReg^.Loaded:= True; | ||||
|         NewReg^.Driver_Load(nil); | ||||
|     end; | ||||
| @@ -336,9 +341,18 @@ begin | ||||
|         end; | ||||
|         dev_list^.Next:= new_dev; | ||||
|     end; | ||||
|     console.output('Driver Management', 'New Device Registered: '); | ||||
|     console.writestringln(new_dev^.Device_Name); | ||||
|     while drv <> nil do begin | ||||
|         if identifiers_match(drv^.Identifier, DeviceID) then begin | ||||
|             console.output('Driver Management', 'Device/Driver Match: '); | ||||
|             console.writestring(new_dev^.Device_Name); | ||||
|             console.writestring('->'); | ||||
|             console.writestringln(drv^.Driver_Name); | ||||
|             if drv^.Driver_Load(ptr) then begin | ||||
|                 console.output('Driver Management', 'Driver ('); | ||||
|                 console.writestring(drv^.Driver_Name); | ||||
|                 console.writestringln(') successfully loaded.'); | ||||
|                 drv^.Loaded:= true; | ||||
|                 new_dev^.Driver_Loaded:= true; | ||||
|                 new_dev^.Driver:= drv; | ||||
|   | ||||
							
								
								
									
										10
									
								
								src/gdt.pas
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/gdt.pas
									
									
									
									
									
								
							| @@ -58,7 +58,7 @@ end; | ||||
|  | ||||
| procedure flush; | ||||
| begin | ||||
|     console.writestringln('GDT: FLUSH.'); | ||||
|     console.outputln('GDT','FLUSH.'); | ||||
|     flush_gdt(uint32(@gdt_pointer)); | ||||
| end; | ||||
|  | ||||
| @@ -70,7 +70,7 @@ end; | ||||
|  | ||||
| procedure reload; | ||||
| begin | ||||
|     console.writestringln('GDT: RELOAD.'); | ||||
|     console.outputln('GDT','RELOAD.'); | ||||
|     reload_gdt(uint32(@gdt_pointer)); | ||||
| end; | ||||
|  | ||||
| @@ -90,14 +90,14 @@ begin | ||||
|     gdt_entries[Gate_Number].limit_low   := (Limit AND $FFFF); | ||||
|     gdt_entries[Gate_Number].granularity := ((Limit SHR 16) AND $0F) OR (Granularity AND $F0); | ||||
|     gdt_entries[Gate_Number].access      := Access;     | ||||
|     console.writestring('GDT: GATE '); | ||||
|     console.output('GDT','GATE '); | ||||
|     console.writeint(Gate_Number); | ||||
|     console.writestringln(' SET.'); | ||||
| end; | ||||
|  | ||||
| procedure init(); | ||||
| begin | ||||
|     console.writestringln('GDT: INIT START.'); | ||||
|     console.outputln('GDT','INIT START.'); | ||||
|     gdt_pointer.limit:= 0; | ||||
|     gdt_pointer.base  := uint32(@gdt_entries);   | ||||
|     set_gate($00, $00, $00,       $00, $00); //OFFSET: 0 | ||||
| @@ -106,7 +106,7 @@ begin | ||||
|     set_gate($03, $00, $FFFFFFFF, $FA, $CF); //OFFSET: 24 | ||||
|     set_gate($04, $00, $FFFFFFFF, $F2, $CF); //OFFSET: 32 | ||||
|     flush; | ||||
|     console.writestringln('GDT: INIT END.'); | ||||
|     console.outputln('GDT','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
							
								
								
									
										10
									
								
								src/idt.pas
									
									
									
									
									
								
							
							
						
						
									
										10
									
								
								src/idt.pas
									
									
									
									
									
								
							| @@ -52,7 +52,7 @@ begin | ||||
|     IDT_Entries[Number].selector:= Selector; | ||||
|     IDT_Entries[Number].flags:= Flags; | ||||
|     IDT_Entries[Number].always_0:= $00; | ||||
|     console.writestring('IDT: GATE '); | ||||
|     console.output('IDT','GATE '); | ||||
|     console.writeint(Number); | ||||
|     console.writestringln(' SET.'); | ||||
| end; | ||||
| @@ -65,14 +65,14 @@ end; | ||||
|  | ||||
| procedure init(); | ||||
| begin | ||||
|     console.writestringln('IDT: INIT START.'); | ||||
|     console.outputln('IDT','INIT START.'); | ||||
|     IDT_Pointer.limit:= (sizeof(TIDT_Entry) * 256) - 1; | ||||
|     IDT_Pointer.base:= uint32(@IDT_Entries); | ||||
|     console.writestringln('IDT: CLEAR.'); | ||||
|     console.outputln('IDT','CLEAR.'); | ||||
|     util.memset(uint32(@IDT_Entries[0]), 0, sizeof(TIDT_Entry) * 256); | ||||
|     console.writestringln('IDT: LOAD.'); | ||||
|     console.outputln('IDT','LOAD.'); | ||||
|     load(uint32(@IDT_Pointer)); | ||||
|     console.writestringln('IDT: INIT END.'); | ||||
|     console.outputln('IDT','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -19,7 +19,7 @@ implementation | ||||
|  | ||||
| procedure init(); | ||||
| begin | ||||
|     console.writestringln('IRQ: INIT START.'); | ||||
|     console.outputln('IRQ','INIT START.'); | ||||
|     outb($20, $11); | ||||
|     outb($A0, $11); | ||||
|     outb($21, $20); | ||||
| @@ -30,7 +30,7 @@ begin | ||||
|     outb($A1, $01); | ||||
|     outb($21, $00); | ||||
|     outb($A1, $00); | ||||
|     console.writestringln('IRQ: INIT END.'); | ||||
|     console.outputln('IRQ','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -24,7 +24,7 @@ implementation | ||||
|  | ||||
| procedure init(); | ||||
| begin | ||||
|     console.writestringln('ISR: INIT START.'); | ||||
|     console.outputln('ISR','INIT START.'); | ||||
|     ISR0.register();  // Divide-By-Zero | ||||
|     ISR1.register();  // Debug | ||||
|     ISR2.register();  // Non-Maskable Inturrupt | ||||
| @@ -49,7 +49,7 @@ begin | ||||
|     ISR33.register(); // Keyboard | ||||
|     ISR40.register(); // 1024/s Timer | ||||
|     ISR44.register(); // Mouse | ||||
|     console.writestringln('ISR: INIT END.'); | ||||
|     console.outputln('ISR','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -89,8 +89,8 @@ begin | ||||
|  | ||||
|      if (multibootmagic <> MULTIBOOT_BOOTLOADER_MAGIC) then begin | ||||
|         console.setdefaultattribute(console.combinecolors(Red, Black)); | ||||
|         console.writestringln('Multiboot Compliant Boot-Loader Needed!'); | ||||
|         console.writestringln('HALTING'); | ||||
|         console.outputln('KERNEL', 'Multiboot Compliant Boot-Loader Needed!'); | ||||
|         console.outputln('KERNEL', 'HALTING.'); | ||||
|         util.halt_and_catch_fire; | ||||
|      end; | ||||
|  | ||||
| @@ -99,9 +99,10 @@ begin | ||||
|         MOV dds, CS | ||||
|      end; | ||||
|      if dds = $08 then begin | ||||
|         console.writestringlnex('GDT: LOAD SUCCESS.', console.combinecolors(Green, Black)); | ||||
|         console.outputln('KERNEL', 'GDT: LOAD SUCCESS.'); | ||||
|      end else begin | ||||
|         console.writestringlnex('GDT: LOAD FAIL.', console.combinecolors(Red, Black)); | ||||
|         console.outputln('KERNEL', 'GDT: LOAD FAIL.'); | ||||
|         console.outputln('KERNEL', 'HALTING.'); | ||||
|         halt_and_catch_fire; | ||||
|      end; | ||||
|  | ||||
| @@ -121,7 +122,7 @@ begin | ||||
|      isr32.hook(uint32(@bios_data_area.tick_update)); | ||||
|  | ||||
|      //drivers | ||||
|      console.writestringln('DRIVERS: INIT BEGIN.'); | ||||
|      console.outputln('KERNEL', 'DRIVERS: INIT BEGIN.'); | ||||
|      keyboard.init(keyboard_layout); | ||||
|      mouse.init(); | ||||
|      testdriver.init(); | ||||
| @@ -130,7 +131,7 @@ begin | ||||
|      //Nothing beyond here | ||||
|      USB.init(); | ||||
|      pci.init(); | ||||
|      console.writestringln('DRIVERS: INIT END.'); | ||||
|      console.outputln('KERNEL', 'DRIVERS: INIT END.'); | ||||
|  | ||||
|      console.writestringln(''); | ||||
|      console.setdefaultattribute(console.combinecolors(Green, Black)); | ||||
|   | ||||
| @@ -86,7 +86,7 @@ var | ||||
|     i : uint32; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('LMM: INIT BEGIN.'); | ||||
|     console.outputln('LMM','INIT BEGIN.'); | ||||
|     Root_Page:= PHeapPage(new_lmm_page); | ||||
|     Search_Page:= Root_Page; | ||||
|     Root_Page^.Next_Page:= 0; | ||||
| @@ -96,7 +96,7 @@ begin | ||||
|         Root_Page^.Entries[i].Root:= False; | ||||
|         Root_Page^.Entries[i].Last:= False; | ||||
|     end;  | ||||
|     console.writestringln('LMM: INIT END.'); | ||||
|     console.outputln('LMM','INIT END.'); | ||||
| end; | ||||
|  | ||||
| function kpalloc(address : uint32) : void; | ||||
|   | ||||
| @@ -109,15 +109,15 @@ end; | ||||
|  | ||||
| procedure init; | ||||
| begin | ||||
|     console.writestringln('PMM: INIT BEGIN.'); | ||||
|     console.outputln('PMM','INIT BEGIN.'); | ||||
|     walk_memory_map; | ||||
|     force_alloc_block(0, 0); | ||||
|     force_alloc_block(1, 0); | ||||
|     force_alloc_block(2, 0); //First 12MiB reserved for Kernel/BIOS. | ||||
|     console.writestring('PMM: '); | ||||
|     console.output('PMM',' '); | ||||
|     console.writeword(nPresent); | ||||
|     console.writestringln('/1024 Block Available for Allocation.'); | ||||
|     console.writestringln('PMM: INIT END.'); | ||||
|     console.outputln('PMM','INIT END.'); | ||||
| end; | ||||
|  | ||||
| function alloc_block(block : uint16; caller : uint32) : boolean; | ||||
|   | ||||
| @@ -105,7 +105,7 @@ end; | ||||
|  | ||||
| procedure init; | ||||
| begin | ||||
|     console.writestringln('SCHEDULER: INIT BEGIN.'); | ||||
|     console.outputln('SCHEDULER','INIT BEGIN.'); | ||||
|     Root_Task:= PScheduler_Entry(kalloc(sizeof(TScheduler_Entry))); | ||||
|     Root_Task^.ThreadID:= 0; | ||||
|     Root_Task^.Priority:= 1; | ||||
| @@ -116,7 +116,7 @@ begin | ||||
|     Active:= False; | ||||
|     isr32.hook(uint32(@delta)); | ||||
|     terminal.registerCommand('TASKS', @terminal_command_tasks, 'List Active Processes.'); | ||||
|     console.writestringln('SCHEDULER: INIT END.'); | ||||
|     console.outputln('SCHEDULER','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -79,7 +79,7 @@ var | ||||
|     cCR3 : uint32; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('TSS: INIT BEGIN.'); | ||||
|     console.outputln('TSS','INIT BEGIN.'); | ||||
|     ptrTaskStateSegment^.ss0:= $08; | ||||
|     ptrTaskStateSegment^.iomap:= sizeof(TTaskStateSegment)-1; | ||||
|     asm | ||||
| @@ -95,7 +95,7 @@ begin | ||||
|         mov AX, 40 | ||||
|         ltr AX | ||||
|     end; | ||||
|     console.writestringln('TSS: INIT END.'); | ||||
|     console.outputln('TSS','INIT END.'); | ||||
| end; | ||||
|  | ||||
| end. | ||||
| @@ -90,13 +90,13 @@ var | ||||
|     i : uint32; | ||||
|  | ||||
| begin | ||||
|     console.writestringln('VMM: INIT BEGIN.'); | ||||
|     console.outputln('VMM','INIT BEGIN.'); | ||||
|     PageDirectory:= load_current_page_directory; | ||||
|     KERNEL_PAGE_DIRECTORY:= PageDirectory; | ||||
|     map_page(KERNEL_PAGE_NUMBER + 1, 1); | ||||
|     map_page(KERNEL_PAGE_NUMBER + 2, 2); | ||||
|     map_page(KERNEL_PAGE_NUMBER + 3, 3); | ||||
|     console.writestringln('VMM: INIT END.'); | ||||
|     console.outputln('VMM','INIT END.'); | ||||
| end; | ||||
|  | ||||
| function map_page_ex(page_number : uint16; block : uint16; PD : PPageDirectory) : boolean; | ||||
| @@ -139,7 +139,7 @@ var | ||||
|     rldpd : uint32; | ||||
|  | ||||
| begin | ||||
|     map_page:= false; | ||||
|     map_page:= false;  | ||||
|     PageDirectory^[page_number].Present:= true; | ||||
|     addr:= block; | ||||
|     PageDirectory^[page_number].Address:= addr SHL 10; | ||||
|   | ||||
		Reference in New Issue
	
	Block a user
	 kieron
					kieron