Compare commits
No commits in common. "569b2f0bcaa8435feda26f68436d56efe03dab94" and "a2f6d7e76d4d7cfa6bb90f254248ae513dc6709f" have entirely different histories.
569b2f0bca
...
a2f6d7e76d
@ -22,18 +22,18 @@ unit AHCI;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
AHCITypes,
|
||||
console,
|
||||
drivermanagement,
|
||||
drivertypes,
|
||||
idetypes,
|
||||
isrmanager,
|
||||
lists,
|
||||
lmemorymanager,
|
||||
PCI,
|
||||
uses
|
||||
util,
|
||||
vmemorymanager;
|
||||
PCI,
|
||||
drivertypes,
|
||||
drivermanagement,
|
||||
lmemorymanager,
|
||||
console,
|
||||
vmemorymanager,
|
||||
AHCITypes,
|
||||
lists,
|
||||
idetypes,
|
||||
isrmanager;
|
||||
|
||||
var
|
||||
ahciControllers : PDList;
|
||||
@ -188,6 +188,9 @@ begin
|
||||
device^.port := port;
|
||||
|
||||
//check if the port is active TODO
|
||||
// if ((port^.sata_status shr 8) <> 1) and ((port^.sata_status and $0F) <> 3) then begin
|
||||
// continue; wrong
|
||||
// end;
|
||||
|
||||
console.writestring('AHCI: signature: ');
|
||||
console.writehexln(port^.signature);
|
||||
@ -278,6 +281,8 @@ begin
|
||||
end;
|
||||
|
||||
controller^.mio^.int_status := $FFFFFFFF;
|
||||
|
||||
// identify_device(controller, DL_Size(controller^.devices) - 1);
|
||||
end;
|
||||
end;
|
||||
end;
|
||||
@ -310,8 +315,8 @@ begin
|
||||
console.writeintln(uint32(device^.device_type));
|
||||
|
||||
//clear any pending interrupts
|
||||
device^.port^.int_status := $FFFFFFFF;
|
||||
device^.port^.int_enable := $0;
|
||||
device^.port^.int_status := $0;
|
||||
device^.port^.int_enable := $FFFFFFFF;
|
||||
|
||||
// Allocate a 512-byte DMA buffer for the IDENTIFY data
|
||||
buffer := kalloc(512);
|
||||
@ -320,6 +325,7 @@ begin
|
||||
// Use command slot 0 for the IDENTIFY command.
|
||||
cmd_header := device^.command_list; // Assuming slot 0 is at the beginning.
|
||||
cmd_header^.cmd_fis_length := sizeof(THBA_FIS_REG_H2D) div sizeof(uint32);
|
||||
// cmd_header^.command := ATA_CMD_IDENTIFY;
|
||||
cmd_header^.wrt := 0;
|
||||
cmd_header^.prdtl := 1;
|
||||
cmd_header^.clear_busy := 1;
|
||||
@ -334,10 +340,10 @@ begin
|
||||
cmd_table^.prdt[0].dbc := 511; // 512 bytes (0-based count)
|
||||
cmd_table^.prdt[0].int := 1; // Interrupt on completion
|
||||
|
||||
// if isATAPI then begin
|
||||
// // ATAPI Identify Device command
|
||||
// buffer[0] := $A1; // ATAPI Identify Device
|
||||
// end;
|
||||
if isATAPI then begin
|
||||
// ATAPI Identify Device command
|
||||
buffer[0] := $A1; // ATAPI Identify Device
|
||||
end;
|
||||
|
||||
// Construct the Command FIS in the command table's CFIS area
|
||||
fis := PHBA_FIS_REG_H2D(@device^.command_table^.cmd_fis);
|
||||
@ -370,7 +376,6 @@ begin
|
||||
repeat
|
||||
cmd := device^.port^.cmd_issue; // Command Issue register
|
||||
tfd := device^.port^.tfd; // Task File Data often contains error/status info.
|
||||
device^.port^.int_status := $FFFFFFFF; // Clear any pending interrupts
|
||||
timeout := timeout + 10;
|
||||
if timeout > 100000 then begin
|
||||
console.writestringln('AHCI: IDENTIFY command timeout');
|
||||
|
@ -26,18 +26,20 @@ interface
|
||||
uses
|
||||
ata,
|
||||
atapi,
|
||||
console,
|
||||
drivermanagement,
|
||||
drivertypes,
|
||||
idetypes,
|
||||
isrmanager,
|
||||
lmemorymanager,
|
||||
storagetypes,
|
||||
strings,
|
||||
terminal,
|
||||
tracer,
|
||||
util,
|
||||
vmemorymanager;
|
||||
drivertypes,
|
||||
console,
|
||||
terminal,
|
||||
drivermanagement,
|
||||
vmemorymanager,
|
||||
lmemorymanager,
|
||||
storagemanagement,
|
||||
strings,
|
||||
tracer,
|
||||
drivemanager,
|
||||
storagetypes,
|
||||
idetypes,
|
||||
isrmanager;
|
||||
|
||||
|
||||
var
|
||||
@ -440,8 +442,8 @@ begin
|
||||
// end;
|
||||
end;
|
||||
|
||||
//register the device TODO
|
||||
// drivemanager.register_device(storageDevice);
|
||||
//register the device
|
||||
drivemanager.register_device(storageDevice);
|
||||
|
||||
end else begin
|
||||
console.writestringln('[IDE] (load_device) Device is not present');
|
||||
|
@ -22,17 +22,19 @@ unit ata;
|
||||
interface
|
||||
|
||||
uses
|
||||
console,
|
||||
drivermanagement,
|
||||
drivertypes,
|
||||
idetypes,
|
||||
lmemorymanager,
|
||||
storagetypes,
|
||||
strings,
|
||||
terminal,
|
||||
tracer,
|
||||
util,
|
||||
vmemorymanager;
|
||||
drivertypes,
|
||||
console,
|
||||
terminal,
|
||||
drivermanagement,
|
||||
vmemorymanager,
|
||||
lmemorymanager,
|
||||
storagemanagement,
|
||||
strings,
|
||||
tracer,
|
||||
drivemanager,
|
||||
storagetypes,
|
||||
idetypes;
|
||||
|
||||
var
|
||||
|
||||
|
@ -27,17 +27,19 @@ unit atapi;
|
||||
interface
|
||||
|
||||
uses
|
||||
console,
|
||||
drivermanagement,
|
||||
drivertypes,
|
||||
idetypes,
|
||||
lmemorymanager,
|
||||
storagetypes,
|
||||
strings,
|
||||
terminal,
|
||||
tracer,
|
||||
util,
|
||||
vmemorymanager;
|
||||
drivertypes,
|
||||
console,
|
||||
terminal,
|
||||
drivermanagement,
|
||||
vmemorymanager,
|
||||
lmemorymanager,
|
||||
storagemanagement,
|
||||
strings,
|
||||
tracer,
|
||||
drivemanager,
|
||||
storagetypes,
|
||||
idetypes;
|
||||
|
||||
var
|
||||
|
||||
@ -52,8 +54,7 @@ var
|
||||
|
||||
implementation
|
||||
uses
|
||||
ata,
|
||||
ide;
|
||||
ide, ata;
|
||||
|
||||
|
||||
procedure ide_irq();
|
||||
|
@ -26,26 +26,8 @@ uses
|
||||
|
||||
type
|
||||
|
||||
TControllerType = (
|
||||
ControllerATA,
|
||||
ControllerATAPI,
|
||||
ControllerUSB,
|
||||
ControllerAHCI,
|
||||
ControllerAHCI_ATAPI,
|
||||
ControllerNVMe,
|
||||
ControllerNET,
|
||||
ControllerRAM,
|
||||
ControllerSCSI
|
||||
);
|
||||
|
||||
TFileSystemType = (
|
||||
FileSystemFAT32,
|
||||
FileSystemExFAT,
|
||||
FileSystemEXT,
|
||||
FileSystemEXT2,
|
||||
FileSystemCDFS,
|
||||
FileSystemOther
|
||||
);
|
||||
TControllerType = (ControllerATA, ControllerATAPI, ControllerUSB, ControllerAHCI,
|
||||
ControllerNET, ControllerRAM, rsvctr1, rsvctr2, rsvctr3);
|
||||
|
||||
PStorage_device = ^TStorage_Device;
|
||||
PDrive_Error = ^TDrive_Error;
|
||||
@ -62,26 +44,13 @@ type
|
||||
controller : TControllerType;
|
||||
controllerId0 : uint32;
|
||||
writable : boolean;
|
||||
volumes : PDList;
|
||||
volumes : PLinkedListBase;
|
||||
writeCallback : PPHIOHook;
|
||||
readCallback : PPHIOHook;
|
||||
maxSectorCount : uint32;
|
||||
sectorSize : uint32; //in bytes
|
||||
start : uint32; //start of device in sectors
|
||||
maxSectorCount : uint32;
|
||||
sectorSize : uint32;
|
||||
end;
|
||||
|
||||
{ Generic storage volume }
|
||||
TStorage_Volume = record
|
||||
id : uint32;
|
||||
device : PStorage_device;
|
||||
name : pchar;
|
||||
fileSystem : TFileSystemType;
|
||||
size : uint32; //size of volume in sectors
|
||||
start : uint32; //start of volume in sectors
|
||||
end;
|
||||
|
||||
PStorage_Volume = ^TStorage_Volume;
|
||||
|
||||
TDrive_Error = record
|
||||
code : uint16;
|
||||
description : pchar;
|
||||
|
@ -1,108 +0,0 @@
|
||||
// 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.
|
||||
|
||||
{
|
||||
Driver->Storage->VolumeManager - Volume manager for storage devices.
|
||||
|
||||
@author(Aaron Hance ah@aaronhance.me)
|
||||
}
|
||||
|
||||
unit volumemanager;
|
||||
|
||||
interface
|
||||
|
||||
uses
|
||||
console,
|
||||
drivermanagement,
|
||||
drivertypes,
|
||||
lists,
|
||||
lmemorymanager,
|
||||
MBR,
|
||||
rtc,
|
||||
serial,
|
||||
storagetypes,
|
||||
strings,
|
||||
terminal,
|
||||
tracer,
|
||||
util;
|
||||
|
||||
var
|
||||
storageDevices : PDList; //index in this array is global drive id
|
||||
volumes : PDList;
|
||||
|
||||
procedure init();
|
||||
procedure register_device(device : PStorage_Device);
|
||||
function discover_volumes(device : PStorage_device) : PDList;
|
||||
|
||||
function get_volume_list() : PDList;
|
||||
|
||||
|
||||
implementation
|
||||
|
||||
procedure init();
|
||||
begin
|
||||
push_trace('VolumeManager.init');
|
||||
|
||||
storageDevices := DL_New(sizeof(PStorage_Device));
|
||||
volumes := DL_New(sizeof(PStorage_Volume));
|
||||
|
||||
//TODO register commnads
|
||||
pop_trace();
|
||||
end;
|
||||
|
||||
procedure register_device(device : PStorage_Device);
|
||||
var
|
||||
diskVolumes : PDList;
|
||||
begin
|
||||
push_trace('VolumeManager.register_device');
|
||||
|
||||
DL_Add(storageDevices);
|
||||
DL_Set(storageDevices, DL_Size(storageDevices) - 1, puint32(device));
|
||||
|
||||
diskVolumes := discover_volumes(device);
|
||||
|
||||
if volumes <> nil then begin
|
||||
volumes := DL_Concat(volumes, diskVolumes);
|
||||
end;
|
||||
|
||||
pop_trace();
|
||||
end;
|
||||
|
||||
function discover_volumes(device : PStorage_device) : PDList;
|
||||
begin
|
||||
push_trace('VolumeManager.discover_volumes');
|
||||
|
||||
discover_volumes := nil;
|
||||
//TODO implement
|
||||
|
||||
pop_trace();
|
||||
end;
|
||||
|
||||
function get_volume_list() : PDList;
|
||||
var
|
||||
newList : PDList;
|
||||
i : uint32;
|
||||
begin
|
||||
push_trace('VolumeManager.get_volume_list');
|
||||
|
||||
//get copy of volume list
|
||||
newList := DL_New(sizeof(PStorage_Volume)); //TODO need to add DL_Copy function
|
||||
|
||||
for i := 0 to DL_Size(volumes) - 1 do begin
|
||||
DL_Add(newList);
|
||||
DL_Set(newList, i, DL_Get(volumes, i));
|
||||
end;
|
||||
end;
|
||||
|
||||
end.
|
File diff suppressed because it is too large
Load Diff
@ -40,13 +40,13 @@ uses
|
||||
testdriver,
|
||||
E1000,
|
||||
IDE,
|
||||
// storagemanagement,
|
||||
// drivemanager,
|
||||
storagemanagement,
|
||||
drivemanager,
|
||||
volumemanager,
|
||||
lists,
|
||||
net,
|
||||
// fat32,
|
||||
// flatfs,
|
||||
fat32,
|
||||
flatfs,
|
||||
isrmanager,
|
||||
faults,
|
||||
fonts,
|
||||
@ -210,8 +210,8 @@ begin
|
||||
drivermanagement.init();
|
||||
tracer.push_trace('kmain.STRMGMT');
|
||||
// storagemanagement.init();
|
||||
// drivemanager.init();
|
||||
// volumemanager.init();
|
||||
drivemanager.init();
|
||||
volumemanager.init();
|
||||
|
||||
{ Hook Timer for Ticks }
|
||||
tracer.push_trace('kmain.TMR');
|
||||
@ -219,8 +219,8 @@ begin
|
||||
TMR_0_ISR.hook(uint32(@bios_data_area.tick_update));
|
||||
|
||||
{ Filsystems }
|
||||
// fat32.init();
|
||||
// flatfs.init();
|
||||
fat32.init();
|
||||
flatfs.init();
|
||||
|
||||
{ Device Drivers }
|
||||
tracer.push_trace('kmain.DEVDRV');
|
||||
|
@ -22,15 +22,7 @@ unit edit;
|
||||
interface
|
||||
|
||||
uses
|
||||
console,
|
||||
keyboard,
|
||||
lmemorymanager,
|
||||
shell,
|
||||
storagemanagement,
|
||||
strings,
|
||||
terminal,
|
||||
tracer,
|
||||
util;
|
||||
console, terminal, keyboard, shell, strings, tracer, storagemanagement, lmemorymanager, util;
|
||||
|
||||
procedure init();
|
||||
|
||||
|
@ -25,7 +25,7 @@ uses
|
||||
tracer, console,
|
||||
//progs
|
||||
base64_prog, md5sum, shell, terminal,
|
||||
netlog, themer,
|
||||
edit, netlog, themer,
|
||||
memview, udpcat, dhclient, vbeinfo;
|
||||
|
||||
{ Initialize all baked-in programs }
|
||||
@ -43,8 +43,8 @@ begin
|
||||
themer.init();
|
||||
tracer.push_trace('progmanager.netlog.init');
|
||||
netlog.init();
|
||||
// tracer.push_trace('progmanager.edit.init');
|
||||
// edit.init();
|
||||
tracer.push_trace('progmanager.edit.init');
|
||||
edit.init();
|
||||
tracer.push_trace('progmanager.udpcat.init');
|
||||
udpcat.init();
|
||||
tracer.push_trace('progmanager.md5sum.init');
|
||||
|
Loading…
x
Reference in New Issue
Block a user