Compare commits

...
3 Commits
Author SHA1 Message Date
Aaron b2ecbe58da Added licensing 2025-03-15 10:43:42 +00:00
Aaron 2014ce4f9c AHCI Progress 2025-03-15 10:42:18 +00:00
Aaron 6cd9ae4f46 Dynamic lists fixes and additions
# Conflicts:
#	src/include/lists.pas
2025-03-14 19:52:41 +00:00
5 changed files with 445 additions and 7 deletions
+61 -5
View File
@@ -1,3 +1,23 @@
// Copyright 2021 Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Drivers->Storage->AHCI->AHCI - AHCI Driver.
@author(Aaron Hance <[email protected]>)
}
unit AHCI; unit AHCI;
interface interface
@@ -10,13 +30,11 @@ uses
lmemorymanager, lmemorymanager,
console, console,
vmemorymanager, vmemorymanager,
AHCITypes; AHCITypes,
lists;
var var
ahciControllers : array[0..255] of pointer; ahciControllers : PDLList;
ahciControllerCount : uint32;
hba : array[0..255] of THBA_Memory;
procedure init(); procedure init();
procedure load(); procedure load();
@@ -36,10 +54,48 @@ begin
devID.id4:= idANY; devID.id4:= idANY;
devID.ex:= nil; devID.ex:= nil;
drivermanagement.register_driver('ATA/PI AHCI Driver', @devID, @load); drivermanagement.register_driver('ATA/PI AHCI Driver', @devID, @load);
//TODO check IDE devices in ide for sata devices
end;
procedure check_ports(controller : PAHCI_Controller);
var
i : uint32;
port : PHBA_Port;
begin
end; end;
procedure load(ptr : void); procedure load(ptr : void);
var
device : PPCI_Device;
controller : PAHCI_Controller;
i : uint32;
base : PHBA_Memory;
begin begin
console.writestringln('AHCI: initilizing a new controller');
if ahciControllers = nil then begin
console.writestringln('AHCI: Initializing controller list');
ahciControllers := DL_New(SizeOf(TAHCI_Controller));
end;
device := PPCI_Device(ptr);
controller := DL_Add(ahciControllers);
controller^.device := device;
base: PHBA_Memory(kpalloc(device^.address5)); // get the base address of the controller
controller^.mio := base;
//enable AHCI mode, TODO check if is not already in AHCI mode and enable it, also perhaps remove if loaded as IDE
base^.ghc := base^.ghc or AHCI_CONTROLLER_MODE;
//clear any pending interrupts
base^.int_status := $FFFFFFFF;
// console.writestringln('AHCI: initilizing a new controller'); // console.writestringln('AHCI: initilizing a new controller');
// ahciControllers[ahciControllerCount] := ptr; // ahciControllers[ahciControllerCount] := ptr;
// hba[ahciControllerCount] := PPCI_Device(ptr)^.address5; // hba[ahciControllerCount] := PPCI_Device(ptr)^.address5;
+90 -1
View File
@@ -1,4 +1,22 @@
// Copyright 2021 Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Drivers->Storage->AHCI->AHCITypes - AHCI Driver Types.
@author(Aaron Hance <[email protected]>)
}
unit AHCITypes; unit AHCITypes;
interface interface
uses uses
@@ -11,6 +29,13 @@ uses
vmemorymanager; vmemorymanager;
const const
AHCI_CONTROLLER_MODE = $80000000;
//device type signatures
SATA_SIG_ATA = $00000101;
SATA_SIG_ATAPI = $EB140101;
SATA_SIG_SEMB = $C33C0101;
SATA_SIG_PM = $96690101;
@@ -72,6 +97,8 @@ type
ports: array[0..31] of THBA_Port; ports: array[0..31] of THBA_Port;
end; end;
PHBA_Memory = ^THBA_Memory;
{ {
AHCI Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface AHCI Host Bus Adapter (HBA) FIS (Frame Information Structure) Interface
This structure is used to access the AHCI HBA's FIS (Frame Information Structure) This structure is used to access the AHCI HBA's FIS (Frame Information Structure)
@@ -163,10 +190,72 @@ type
PHBA = ^THBA; PHBA = ^THBA;
//////////////////////////////////////////
//////////// Asuro AHCI types ////////////
//////////////////////////////////////////
{
Device type enum
}
TDeviceType = (
SATA,
ATAPI,
SEMB,
PM
);
{
controller reference
}
TAHCI_Controller = bitpacked record
pci_device : PPCI_Device;
mio: PHBA_Memory;
devices : array[0..31] of uint8; //TODO type for devices
end;
PAHCI_Controller = ^TAHCI_Controller;
function get_device_type(sig : uint32) : TDeviceType;
function get_device_type_string(deive_type : TDeviceType) : string;
implementation implementation
function get_device_type(sig : uint32) : TDeviceType;
begin
case sig of
SATA_SIG_ATA: begin
get_device_type := SATA;
end;
SATA_SIG_ATAPI: begin
get_device_type := ATAPI;
end;
SATA_SIG_SEMB: begin
get_device_type := SEMB;
end;
SATA_SIG_PM: begin
get_device_type := PM;
end;
end;
end;
function get_device_type_string(deive_type : TDeviceType) : string;
begin
case deive_type of
SATA: begin
get_device_type_string := 'SATA';
end;
ATAPI: begin
get_device_type_string := 'ATAPI';
end;
SEMB: begin
get_device_type_string := 'SEMB';
end;
PM: begin
get_device_type_string := 'PM';
end;
end;
end;
end. end.
+19
View File
@@ -1,3 +1,22 @@
// Copyright 2021 Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Drivers->Storage->ide - IDE Driver.
@author(Aaron Hance <[email protected]>)
}
unit ide; unit ide;
interface interface
+19
View File
@@ -1,3 +1,22 @@
// Copyright 2021 Aaron Hance
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
{
Drivers->Storage->ATA - ATA Driver.
@author(Aaron Hance <[email protected]>)
}
unit ata; unit ata;
interface interface
+256 -1
View File
File diff suppressed because it is too large Load Diff