Compare commits

...
24 Commits
Author SHA1 Message Date
Aaron 837d69a44b ide rework again 2025-03-09 13:50:11 +00:00
t3hn3rd f0d5eb21f1 DevOps Workflow Improvements
- `VirtualBox-Wrapper.ps1` now takes 'up' or 'down' as opposed to a machine name. This allows start/stop of a virtualmachine.
- `VirtualBox-Wrapper.ps1` now relies on a gitignored `localenv.json` to work.
- `VirtualBox-Wrapper.ps1` can also optionally monitor the log file generated from the serial adapter in VirtualBox.
- `readme.md` updated to provide instructions on how to populate the `localenv.json` file.
- `tasks.json` updated to have a "Clean" task to --remove-orphans, the Build task depends on this.
- `tasks.json` updated to have a "Close VirtualBox" task, this runs the `virtualbox-wrapper.ps1` in 'down' mode. The Build task depends on this.
- `launch.json` updated to run the `VirtualBox-Wrapper.ps1` with the "-Command up" argument, instead of machine name.
- .gitignore updated to ignore any instances of `localenv.json`.

# Conflicts:
#	.gitignore
2025-03-09 13:49:53 +00:00
t3hn3rd 07e9095582 VirtualBox 7 Compatability Changes
- Created a PowerShell script `virtualbox-wrapper.ps1` to wrap calls to vboxmanage and only exit once the virtual machine has been terminated.
- Updated launch.json to use the PowerShell launch type to launch `virtualbox-wrapper.ps1` with the machine name supplied as an argument.
- Updated `readme.md` to reflect these changes.

# Conflicts:
#	.vscode/launch.json
2025-03-08 21:09:13 +00:00
Aaron 72769fbef7 fix 2022-09-28 16:15:45 +01:00
Aaron 95599c0e7c fix 2022-09-28 16:14:06 +01:00
Aaron fcaafa0d12 Started aadding file handle stuff to volume manager 2022-09-28 16:04:51 +01:00
Aaron e490b95f1d comments 2022-09-27 17:23:42 +01:00
Aaron b601080960 Added delete files and directory functions to flatfs 2022-02-03 02:21:51 +00:00
Aaron 27177979a2 Flatfs reading and writing files and directories done 2022-02-03 01:21:37 +00:00
Aaron f88a282893 Progress on flatfs 2022-02-02 23:19:30 +00:00
Aaron ff4c597ff3 Work on storage and flat file system 2022-02-01 05:07:52 +00:00
Aaron 24c371cab1 Added new String functions 2022-01-31 00:34:38 +00:00
Aaron 7588a4c9cb Revert "Updated Strings unit with new functions"
This reverts commit 5cb415c76b.
2022-01-31 00:31:01 +00:00
Aaron 5cb415c76b Updated Strings unit with new functions 2022-01-31 00:27:02 +00:00
Aaron 118d8b0c03 Merge branch 'feature/storage-system' of https://gitlab.spexeah.com/spexeah/asuro into feature/storage-system
# Conflicts:
#	src/driver/storage/drivemanager.pas
#	src/driver/storage/storagemanagement.pas
2022-01-30 00:42:37 +00:00
Aaron 28caca3bcc commiting before rebase 2022-01-30 00:34:52 +00:00
Aaron 6476a774dc More progress and fixes 2022-01-30 00:34:52 +00:00
Aaron e791edb02a Progress 2022-01-30 00:34:51 +00:00
Aaron da36f6fabb Continued new volume management stuff. 2022-01-30 00:34:51 +00:00
Aaron 97e1a18253 Restructuring and expanding storage system. 2022-01-30 00:34:51 +00:00
Aaron 88a850e8fc More progress and fixes 2022-01-29 22:21:10 +00:00
Aaron 10c9194c5f Progress 2022-01-29 20:05:11 +00:00
Aaron 94b477d8f7 Continued new volume management stuff. 2021-06-25 01:48:20 +01:00
Aaron ba38f4fd19 Restructuring and expanding storage system. 2021-06-23 21:22:06 +01:00
21 changed files with 3084 additions and 516 deletions
+1 -2
View File
@@ -10,5 +10,4 @@
/*.sh~ /*.sh~
/*.img /*.img
src/include/asuro.pas src/include/asuro.pas
.vscode/launch.json localenv.json
.vscode
+3 -10
View File
@@ -3,18 +3,11 @@
{ {
"name":"Run", "name":"Run",
"request": "launch", "request": "launch",
"type": "coreclr", "type": "PowerShell",
"preLaunchTask": "Build", "preLaunchTask": "Build",
"program": "VBoxSDL", "script": "${workspaceFolder}/virtualbox-wrapper.ps1",
"args": [ "args": ["-Command", "up"],
"--comment",
"Asuro",
"--startvm",
"7d395c96-891c-4139-b77d-9b6b144b0b93"
],
"cwd": "${workspaceFolder}", "cwd": "${workspaceFolder}",
"console": "internalConsole",
"internalConsoleOptions": "neverOpen"
} }
] ]
} }
+24 -2
View File
@@ -9,14 +9,18 @@
"command": "docker-compose", "command": "docker-compose",
"args": [ "args": [
"run", "run",
"builder" "builder",
], ],
"type": "shell", "type": "shell",
"problemMatcher": [], "problemMatcher": [],
"group": { "group": {
"kind": "build", "kind": "build",
"isDefault": true "isDefault": true
} },
"dependsOn": [
"Close VirtualBox",
"Clean"
]
}, },
{ {
"label": "Build (Builder)", "label": "Build (Builder)",
@@ -26,6 +30,24 @@
"builder" "builder"
], ],
"type": "shell" "type": "shell"
},
{
"label": "Clean",
"command": "docker-compose",
"args": [
"down",
"--remove-orphans"
],
"type": "shell"
},
{
"label": "Close VirtualBox",
"command": "./virtualbox-wrapper.ps1",
"args": [
"-Command",
"down"
],
"type": "shell"
} }
] ]
} }
+32
View File
@@ -0,0 +1,32 @@
#Flat filesystem
A super simple filesystem for asuro. Folders are emulated in filenames.
Starts with disk info sector, sector 0 of volume
---
#### disk info
jmp2boot : ubit24;
OEMName : array[0..7] of char;
version : uint16 // numerical version of filesystem
sectorCount : uint16;
fileCount : uint16
signature : uint32 = 0x0B00B1E5
the Rest of the sector is reserved
---
Starting from sector 1 is the file table. Table size is determined by entry size (64) * fileCount
---
####File entry
name : array[0..59] of char //file name max 60 chars
fileStart : 16bit // start sector of data
fileSize : 16bit // data size in sectors
---
-1
View File
@@ -1,4 +1,3 @@
version: "3.9"
services: services:
builder: builder:
build: . build: .
+20 -23
View File
@@ -13,8 +13,8 @@ We welcome everyone to give building/breaking/fixing/shooting Asuro a go, feel f
I don't think this needs an explaination. I don't think this needs an explaination.
* [VSCode (Optional, but highly recommended)](https://code.visualstudio.com/) * [VSCode (Optional, but highly recommended)](https://code.visualstudio.com/)
Visual Studio code is our IDE of choice, and we have a number of recommended plugins. Visual Studio code is our IDE of choice, and we have a number of recommended plugins.
* [C# Plugin by Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-dotnettools.csharp) * [PowerShell Plugin by Microsoft](https://marketplace.visualstudio.com/items?itemName=ms-vscode.powershell)
This plugin gives you the ability to use the 'coreclr' task type, allowing the automatic launching of virtualbox with the resulting image generated during compilation of Asuro. This plugin gives you the ability to use the 'PowerShell' task type, allowing the automatic launching of virtualbox with the resulting image generated during compilation of Asuro.
* [VirtualBox](https://www.virtualbox.org/) * [VirtualBox](https://www.virtualbox.org/)
Virtualbox is our Virtualisation environment of choice, don't ask why, it just is. Virtualbox is our Virtualisation environment of choice, don't ask why, it just is.
@@ -27,7 +27,7 @@ We welcome everyone to give building/breaking/fixing/shooting Asuro a go, feel f
3. Install Docker for Windows. 3. Install Docker for Windows.
4. Install Git for Windows. 4. Install Git for Windows.
5. Install VSCode & the listed plugins. 5. Install VSCode & the listed plugins.
6. Install VirtualBox. 6. Install VirtualBox (v7+).
7. Clone this repository. 7. Clone this repository.
8. Run the following command in the root of the repo to build the docker image: 8. Run the following command in the root of the repo to build the docker image:
```powershell ```powershell
@@ -50,32 +50,29 @@ We welcome everyone to give building/breaking/fixing/shooting Asuro a go, feel f
```xml ```xml
<Machine uuid="{7d395c96-891c-4139-b77d-9b6b144b0b93}" name="Asuro" OSType="Linux" snapshotFolder="Snapshots" lastStateChange="2021-06-20T20:33:07Z"> <Machine uuid="{7d395c96-891c-4139-b77d-9b6b144b0b93}" name="Asuro" OSType="Linux" snapshotFolder="Snapshots" lastStateChange="2021-06-20T20:33:07Z">
``` ```
Copy the uuid, in our case `7d395c96-891c-4139-b77d-9b6b144b0b93` and replace the uuid found in `.vscode\launch.json` under `args`, so that it looks something like this: Copy the uuid, in our case `7d395c96-891c-4139-b77d-9b6b144b0b93` & create a `localenv.json` file in the project root with the following content:
```json ```json
{ {
"configurations": [ "VirtualBox":{
{ "MachineName":"<YOUR_UUID_OR_MACHINE_NAME>"
"name":"Run", }
"request": "launch",
"type": "coreclr",
"preLaunchTask": "Build",
"program": "VBoxSDL",
"args": [
"--comment",
"Asuro",
"--startvm",
"<YOUR UUID HERE>"
],
"cwd": "${workspaceFolder}",
"console": "internalConsole",
"internalConsoleOptions": "neverOpen"
}
]
} }
``` ```
This will allow VSCode to automatically launch VirtualBox once Asuro has been compiled. This will allow VSCode to automatically launch VirtualBox once Asuro has been compiled.
You can also enable the serial adapter "COM1" in mode "Raw File", give it a path, and provide this path in the `localenv.json` as follows:
```json
{
"VirtualBox" : {
"MachineName": "<YOUR_UUID_OR_MACHINE_NAME>",
"LogLocation": "Fully\\Qualified\\Path\\To\\Your\\Log\\File"
}
}
```
This will allow you to see the console output from Asuro in your host terminal.
13. Open your project folder in VSCode, use CTRL+SHIFT+B to build & F5 to build + run in VBox. 13. Open your project folder in VSCode, use CTRL+SHIFT+B to build & F5 to build + run in VBox.
14. Congratulations! You can now play with Asuro! 14. Congratulations! You can now play with Asuro!
### Gotchas ### Notes & Gotchas
- The above process has been updated to be compatible with VirtualBox 7+, in which VBoxSDL was removed and vboxmanage should be used in its place. A small wrapper powershell script is used to achieve this.
- It was noted that Windows builds above `20H2` seem to have issues installing WSL2. We may have to wait for a patch from Microsoft to fix this. Our devs are currently using build `20H2`. - It was noted that Windows builds above `20H2` seem to have issues installing WSL2. We may have to wait for a patch from Microsoft to fix this. Our devs are currently using build `20H2`.
+295 -388
View File
File diff suppressed because it is too large Load Diff
+81
View File
@@ -0,0 +1,81 @@
{
Driver->Storage->MBR Master boot record
@author(Aaron Hance [email protected])
}
unit mbr;
interface
uses
tracer;
type
PMaster_Boot_Record = ^TMaster_Boot_Record;
PPartition_table = ^TPartition_table;
TPartition_table = bitpacked record
attributes : uint8;
CHS_start : array[0..2] of uint8;
system_id : uint8;
CHS_end : array[0..2] of uint8;
LBA_start : uInt32;
sector_count : uInt32;
end;
TMaster_Boot_Record = bitpacked record
bootstrap : array[0..439] of uint8;
signature : uint32;
rsv : uint16;
partition : array[0..3] of TPartition_table;
boot_sector : uint16;
end;
T24bit = array[0..2] of uint8;
function get_bootable(partition_table : PPartition_table) : boolean;
procedure set_bootable(partition_table : PPartition_table);
procedure setup_partition(partition_table : PPartition_table; address : uint32; sectorSize : uint32);
implementation
{ convert LBA address to CHS address}
function LBA_2_CHS(lba : uint32) : T24bit;
var
dat : T24bit;
begin
//TODO impliment procedure
LBA_2_CHS := dat;
end;
{ Set a partition struct to be bootable}
procedure set_bootable(partition_table : PPartition_table);
begin
push_trace('MBR.set_bootable');
//set the bootble bit in attributes
partition_table^.attributes := (partition_table^.attributes and $80);
end;
{ Check a partitions bootable bit }
function get_bootable(partition_table : PPartition_table) : boolean;
begin
push_trace('MBR.get_bootable');
//get the bootble bit in attributes
get_bootable := (partition_table^.attributes and $80) = $80;
end;
{ Setup a partition table struct }
procedure setup_partition(partition_table : PPartition_table; address : uint32; sectorSize : uint32);
begin
push_trace('MBR.setup_partition');
//set values in both LBA and CHS addressing schemes
partition_table^.LBA_start := address;
partition_table^.sector_count := sectorSize;
partition_table^.CHS_start := LBA_2_CHS(address);
partition_table^.CHS_start := LBA_2_CHS(address + sectorSize);
push_trace('MBR.setup_partition.end');
end;
end.
File diff suppressed because it is too large Load Diff
View File
File diff suppressed because it is too large Load Diff
+29 -9
View File
@@ -10,14 +10,16 @@ interface
uses uses
console, console,
storagemanagement, util,
util, terminal, terminal,
lmemorymanager, lmemorymanager,
strings, strings,
lists, lists,
tracer, tracer,
serial, serial,
rtc; rtc,
volumemanager,
storagetypes;
type type
@@ -89,7 +91,7 @@ var
filesystem : TFilesystem; filesystem : TFilesystem;
procedure init; procedure init;
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32); procedure create_volume(volume : PStorage_Volume; sectors : uint32; start : uint32; config : puint32);
procedure detect_volumes(disk : PStorage_Device); procedure detect_volumes(disk : PStorage_Device);
//function writeDirectory(volume : PStorage_volume; directory : pchar; attributes : uint32) : uint8; // need to handle parent table cluster overflow, need to take attributes //function writeDirectory(volume : PStorage_volume; directory : pchar; attributes : uint32) : uint8; // need to handle parent table cluster overflow, need to take attributes
//function readDirectory(volume : PStorage_volume; directory : pchar; listPtr : PLinkedListBase) : uint8; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error //function readDirectory(volume : PStorage_volume; directory : pchar; listPtr : PLinkedListBase) : uint8; //returns: 0 = success, 1 = dir not exsist, 2 = not directory, 3 = error
@@ -751,7 +753,7 @@ end;
//TODO check directory commands for errors with a clean disk //TODO check directory commands for errors with a clean disk
procedure create_volume(disk : PStorage_Device; sectors : uint32; start : uint32; config : puint32); procedure create_volume(volume : PStorage_Volume; sectors : uint32; start : uint32; config : puint32);
var var
buffer : puint32; buffer : puint32;
bt: puint32; bt: puint32;
@@ -772,9 +774,18 @@ var
programFileArray : byteArray8 = ('P','R','O','G','R','A','M','S'); programFileArray : byteArray8 = ('P','R','O','G','R','A','M','S');
rootCluster : uint32 = 1; rootCluster : uint32 = 1;
sysArray : byteArray8 = ('S','Y','S','T','E','M',' ',' ');
progArray : byteArray8 = ('P','R','O','G','R','A','M','S');
userArray : byteArray8 = ('U','S','E','R',' ',' ',' ',' ');
status : puint32;
disk : PStorage_device;
begin //maybe increase buffer size by one? begin //maybe increase buffer size by one?
push_trace('fat32.create_volume()'); push_trace('fat32.create_volume()');
disk := volume^.device;
// zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 )); // zeroBuffer:= puint32(kalloc( disk^.sectorSize * 4 ));
// memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4); // memset(uint32(zeroBuffer), 0, disk^.sectorSize * 4);
@@ -811,7 +822,7 @@ begin //maybe increase buffer size by one?
bootRecord^.jmp2boot := $0; //TODO impliment boot jump bootRecord^.jmp2boot := $0; //TODO impliment boot jump
bootRecord^.OEMName := asuroArray; bootRecord^.OEMName := asuroArray;
bootRecord^.sectorSize := disk^.sectorsize; bootRecord^.sectorSize := disk^.sectorsize;
bootRecord^.spc := config^; bootRecord^.spc := 1;
bootRecord^.rsvSectors := 32; //32 is standard bootRecord^.rsvSectors := 32; //32 is standard
bootRecord^.numFats := 1; bootRecord^.numFats := 1;
bootRecord^.mediaDescp := $F8; bootRecord^.mediaDescp := $F8;
@@ -873,8 +884,16 @@ begin //maybe increase buffer size by one?
disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer); disk^.writecallback(disk, dataStart + (config^ * rootCluster), 1, buffer);
memset(uint32(buffer), 0, disk^.sectorsize);
status := puint32(kalloc(sizeof(uint32)));
writeDirectory(volume, '', sysArray, $10, status, '');
kfree(buffer); kfree(buffer);
end; end;
procedure detect_volumes(disk : PStorage_Device); procedure detect_volumes(disk : PStorage_Device);
@@ -903,11 +922,11 @@ begin
if (puint32(buffer)[127] = $55AA) and (PBootRecord(buffer)^.bsignature = $29) then begin //TODO partition table if (puint32(buffer)[127] = $55AA) and (PBootRecord(buffer)^.bsignature = $29) then begin //TODO partition table
console.writestringln('FAT32: volume found!'); console.writestringln('FAT32: volume found!');
volume^.device:= disk; volume^.device:= disk;
volume^.sectorStart:= 1; volume^.sectorStart:= 1; //THIS MAKE SURE IF NOT FUCKY, cos im getting info from 2
volume^.sectorSize:= PBootRecord(buffer)^.sectorSize; volume^.sectorSize:= PBootRecord(buffer)^.sectorSize;
volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first volume^.freeSectors:= 1000000; //TODO implement get free sectors need FSINFO implemented first
volume^.filesystem := @filesystem; volume^.filesystem := @filesystem;
storagemanagement.register_volume(disk, volume); // storagemanagement.register_volume(disk, volume); TODO repalce with new thing
end; end;
kfree(buffer); kfree(buffer);
@@ -917,6 +936,7 @@ procedure init();
begin begin
push_trace('fat32.init()'); push_trace('fat32.init()');
filesystem.sName:= 'FAT32'; filesystem.sName:= 'FAT32';
filesystem.system_id:= $01;
filesystem.readDirCallback:= @readDirectoryGen; filesystem.readDirCallback:= @readDirectoryGen;
filesystem.createDirCallback:= @writeDirectoryGen; filesystem.createDirCallback:= @writeDirectoryGen;
filesystem.createcallback:= @create_volume; filesystem.createcallback:= @create_volume;
@@ -924,7 +944,7 @@ begin
filesystem.writecallback:= @writeFile; filesystem.writecallback:= @writeFile;
filesystem.readcallback := @readFile; filesystem.readcallback := @readFile;
storagemanagement.register_filesystem(@filesystem); volumemanager.register_filesystem(@filesystem);
end; end;
end. end.
File diff suppressed because it is too large Load Diff
+140
View File
@@ -0,0 +1,140 @@
// 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->IDE->idetypes - IDE device types and constants.
@author(Aaron Hance <[email protected]>)
}
unit idetypes;
interface
const
ATA_SR_BUSY = $80; //BUSY
ATA_SR_DRDY = $40; //DRIVE READY
ATA_SR_DF = $20; //DRIVE WRITE FAULT
ATA_SR_DSC = $10; //DRIVE SEEK COMPLETE
ATA_SR_DRQ = $08; //DATA REQUEST READY
ATA_SR_CORR = $04; //CORRECTED DATA
ATA_SR_IDX = $02; //INLEX
ATA_SR_ERR = $01; //ERROR
ATA_ER_BBK = $80; //BAD SECTOR
ATA_ER_UNC = $40; //UNCORRECTABLE DATA
ATA_ER_MC = $20; //NO MEDIA
ATA_ER_IDNF = $10; //ID MARK NOT FOUND
ATA_ER_MCR = $08; //NO MEDIA
ATA_ER_ABRT = $04; //COMMAND ABORTED
ATA_ER_TK0NF = $02; //TRACK 0 NOT FOUND
ATA_ER_AMNF = $01; //NO ADDRESS MARK
ATA_CMD_READ_PIO = $20;
ATA_CMD_READ_PIO_EXT = $24;
ATA_CMD_READ_DMA = $C8;
ATA_CMD_READ_DMA_EXT = $25;
ATA_CMD_WRITE_PIO = $30;
ATA_CMD_WRITE_PIO_EXT = $34;
ATA_CMD_WRITE_DMA = $CA;
ATA_CMD_WRITE_DMA_EXT = $35;
ATA_CMD_CACHE_FLUSH = $E7;
ATA_CMD_CACHE_FLUSH_EXT = $EA;
ATA_CMD_PACKET = $A0;
ATA_CMD_IDENTIFY_PACKET = $A1;
ATA_CMD_IDENTIFY = $EC;
ATAPI_CMD_READ = $A8;
ATAPI_CMD_EJECT = $1B;
ATA_IDENT_DEVICETYPE = $0;
ATA_IDENT_CYLINDERS = $2;
ATA_IDENT_HEADS = $6;
ATA_IDENT_SECOTRS = $12;
ATA_IDENT_SERIAL = $20;
ATA_IDENT_MODEL = $54;
ATA_IDENT_CAPABILITIES = $98;
ATA_IDENT_FIELDVALID = $106;
ATA_IDENT_MAX_LBA = $120;
ATA_IDENT_COMMANDSETS = $164;
ATA_IDENT_MAX_LBA_EXT = $200;
ATA_REG_DATA = $00;
ATA_REG_ERROR = $01;
ATA_REG_FEATURES = $01;
ATA_REG_SECCOUNT = $02;
ATA_REG_LBA0 = $03;
ATA_REG_LBA1 = $04;
ATA_REG_LBA2 = $05;
ATA_REG_HDDEVSEL = $06;
ATA_REG_COMMAND = $07;
ATA_REG_STATUS = $07;
ATA_REG_SECCOUNT1 = $08;
ATA_REG_LBA3 = $09;
ATA_REG_LBA4 = $0A;
ATA_REG_LBA5 = $0B;
ATA_REG_CONTROL = $0C;
ATA_REG_ALTSTATUS = $0C;
ATA_REG_DEVADDRESS = $0D;
ATA_DEVICE_MASTER = $A0;
ATA_DEVICE_SLAVE = $B0;
ATA_PRIMARY_BASE = $1F0;
ATA_PRIMARY_BASE1 = $3F6;
ATA_SECONDARY_BASE = $170; //todo check this
ATA_SECONDARY_BASE1 = $376; //todo check this
ATA_INTERRUPT_PRIMARY = $3F6;
ATA_INTERRUPT_SECONDARY = $376;
type
TPortMode = (P_READ, P_WRITE);
TIdentResponse = array[0..255] of uint16;
PIdentResponse = ^TIdentResponse;
TIDE_Channel_Registers = record
base : uint16;
ctrl : uint16;
bmide : uint16;
noInter : uint8
end;
TIDE_Status = bitpacked record
Busy : Boolean;
Ready : Boolean;
Fault : Boolean;
Seek : Boolean;
DRQ : Boolean;
CORR : Boolean;
IDDEX : Boolean;
ERROR : Boolean;
end;
PIDE_Status = ^TIDE_Status;
TIDE_Device = record
exists : boolean;
isPrimary : boolean;
isMaster : boolean;
isATAPI : boolean;
status : TIDE_Status;
base : uint16;
info : PIdentResponse;
end;
implementation
end.
File diff suppressed because it is too large Load Diff
File diff suppressed because it is too large Load Diff
+64
View File
@@ -0,0 +1,64 @@
// 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->Include->storagetypes - Structs & Data Shared Across Storage Drivers.
@author(Aaron Hance <[email protected]>)
}
unit storagetypes;
interface
uses
lists;
type
TControllerType = (ControllerATA, ControllerATAPI, ControllerUSB, ControllerAHCI,
ControllerNET, ControllerRAM, rsvctr1, rsvctr2, rsvctr3);
PStorage_device = ^TStorage_Device;
PDrive_Error = ^TDrive_Error;
PPHIOHook = procedure(drive : PStorage_device; addr : uint32; sectors : uint32; buffer : puint32);
PPHIOHook_ = procedure;
byteArray8 = array[0..7] of char;
PByteArray8 = ^byteArray8;
{ Generic storage device }
TStorage_Device = record
id : uint8;
controller : TControllerType;
controllerId0 : uint32;
writable : boolean;
volumes : PLinkedListBase;
writeCallback : PPHIOHook;
readCallback : PPHIOHook;
maxSectorCount : uint32;
sectorSize : uint32;
end;
TDrive_Error = record
code : uint16;
description : pchar;
recoverable : boolean;
end;
implementation
end.
File diff suppressed because it is too large Load Diff
+93
View File
@@ -16,6 +16,7 @@
Include->Strings - String Manipulation. Include->Strings - String Manipulation.
@author(Kieron Morris <[email protected]>) @author(Kieron Morris <[email protected]>)
@author(Aaron Hance <[email protected]>)
} }
unit strings; unit strings;
@@ -33,6 +34,10 @@ function stringCopy(str : pchar) : pchar;
function stringNew(size : uint32) : pchar; function stringNew(size : uint32) : pchar;
function stringSize(str : pchar) : uint32; function stringSize(str : pchar) : uint32;
function stringConcat(str1, str2 : pchar) : pchar; function stringConcat(str1, str2 : pchar) : pchar;
function stringTrim(str : pchar; length : uint32) : pchar;
function stringSub(str : pchar; start, size : uint32) : pchar;
function stringReplace(str, find, replace : pchar) : pchar;
function stringIndexOf(str, find : pchar) : sint32;
function stringContains(str : pchar; sub : pchar) : boolean; function stringContains(str : pchar; sub : pchar) : boolean;
function stringToInt(str : pchar) : uint32; function stringToInt(str : pchar) : uint32;
function hexStringToInt(str : pchar) : uint32; function hexStringToInt(str : pchar) : uint32;
@@ -151,6 +156,94 @@ begin
stringConcat:= result; stringConcat:= result;
end; end;
// Trim the string to the specified length.
function stringTrim(str : pchar; length : uInt32) : pchar;
var
result : pchar;
begin
result:= stringNew(length);
memcpy(uint32(str), uint32(result), length);
stringTrim:= result;
end;
// Return a substring of the string.
function stringSub(str : pchar; start, size : uint32) : pchar;
var
result : pchar;
begin
result:= stringNew(size);
memcpy(uint32(str)+start, uint32(result), size);
stringSub:= result;
end;
// Replace first instance of a string with another.
function stringReplace(str, find, replace : pchar) : pchar;
var
result : pchar;
i, j, k : uint32;
found : boolean;
begin
// Find the first instance of the find string.
i:= 0;
found:= false;
while (i < stringSize(str)) and (not found) do begin
if stringEquals(str+i, find) then begin
found:= true;
end else begin
inc(i);
end;
end;
// If we found the find string, replace it.
if found then begin
result:= stringNew(stringSize(str) - stringSize(find) + stringSize(replace));
j:= 0;
k:= 0;
while i < stringSize(str) do begin
if stringEquals(str+i, find) then begin
memcpy(uint32(replace), uint32(result+j), stringSize(replace));
j:= j + stringSize(replace);
inc(i, stringSize(find));
end else begin
result[j]:= str[i];
inc(j);
inc(i);
end;
end;
stringReplace:= result;
end else begin
stringReplace:= stringCopy(str);
end;
// Return the result.
stringReplace:= result;
end;
// Find the index of the first instance of a string.
function stringIndexOf(str, find : pchar) : sint32;
var
i : uint32;
found : boolean;
begin
i:= 0;
found:= false;
while (i < stringSize(str)) and (not found) do begin
if stringEquals(str+i, find) then begin
found:= true;
end else begin
inc(i);
end;
end;
if found then begin
stringIndexOf:= i;
end else begin
stringIndexOf:= -1;
end;
end;
function stringContains(str : pchar; sub : pchar) : boolean; function stringContains(str : pchar; sub : pchar) : boolean;
var var
strEnd, subEnd, i, j, count : uint32; strEnd, subEnd, i, j, count : uint32;
+7 -1
View File
@@ -41,9 +41,12 @@ uses
E1000, E1000,
IDE, IDE,
storagemanagement, storagemanagement,
drivemanager,
volumemanager,
lists, lists,
net, net,
fat32, fat32,
flatfs,
isrmanager, isrmanager,
faults, faults,
fonts, fonts,
@@ -205,7 +208,9 @@ begin
tracer.push_trace('kmain.DRVMGMT'); tracer.push_trace('kmain.DRVMGMT');
drivermanagement.init(); drivermanagement.init();
tracer.push_trace('kmain.STRMGMT'); tracer.push_trace('kmain.STRMGMT');
storagemanagement.init(); // storagemanagement.init();
drivemanager.init();
volumemanager.init();
{ Hook Timer for Ticks } { Hook Timer for Ticks }
tracer.push_trace('kmain.TMR'); tracer.push_trace('kmain.TMR');
@@ -214,6 +219,7 @@ begin
{ Filsystems } { Filsystems }
fat32.init(); fat32.init();
flatfs.init();
{ Device Drivers } { Device Drivers }
tracer.push_trace('kmain.DEVDRV'); tracer.push_trace('kmain.DEVDRV');

Some files were not shown because too many files have changed in this diff Show More