Compare commits
30
Commits
64bit
...
b2ecbe58da
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b2ecbe58da | ||
|
|
2014ce4f9c | ||
|
|
6cd9ae4f46 | ||
|
|
0855abfd41 | ||
|
|
fd0de9f1d2 | ||
|
|
920aca5bbf | ||
|
|
837d69a44b | ||
|
|
f0d5eb21f1 | ||
|
|
07e9095582 | ||
|
|
72769fbef7 | ||
|
|
95599c0e7c | ||
|
|
fcaafa0d12 | ||
|
|
e490b95f1d | ||
|
|
b601080960 | ||
|
|
27177979a2 | ||
|
|
f88a282893 | ||
|
|
ff4c597ff3 | ||
|
|
24c371cab1 | ||
|
|
7588a4c9cb | ||
|
|
5cb415c76b | ||
|
|
118d8b0c03 | ||
|
|
28caca3bcc | ||
|
|
6476a774dc | ||
|
|
e791edb02a | ||
|
|
da36f6fabb | ||
|
|
97e1a18253 | ||
|
|
88a850e8fc | ||
|
|
10c9194c5f | ||
|
|
94b477d8f7 | ||
|
|
ba38f4fd19 |
No files matched your search
+1
-2
@@ -10,5 +10,4 @@
|
|||||||
/*.sh~
|
/*.sh~
|
||||||
/*.img
|
/*.img
|
||||||
src/include/asuro.pas
|
src/include/asuro.pas
|
||||||
.vscode/launch.json
|
localenv.json
|
||||||
.vscode
|
|
||||||
Vendored
+3
-10
@@ -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"
|
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
Vendored
+24
-2
@@ -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"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -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,4 +1,3 @@
|
|||||||
version: "3.9"
|
|
||||||
services:
|
services:
|
||||||
builder:
|
builder:
|
||||||
build: .
|
build: .
|
||||||
|
|||||||
@@ -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`.
|
||||||
@@ -0,0 +1,112 @@
|
|||||||
|
|
||||||
|
// 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;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
util,
|
||||||
|
PCI,
|
||||||
|
drivertypes,
|
||||||
|
drivermanagement,
|
||||||
|
lmemorymanager,
|
||||||
|
console,
|
||||||
|
vmemorymanager,
|
||||||
|
AHCITypes,
|
||||||
|
lists;
|
||||||
|
|
||||||
|
var
|
||||||
|
ahciControllers : PDLList;
|
||||||
|
|
||||||
|
procedure init();
|
||||||
|
procedure load();
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
procedure init();
|
||||||
|
var
|
||||||
|
devID : TDeviceIdentifier;
|
||||||
|
begin
|
||||||
|
console.writestringln('AHCI: Registering driver');
|
||||||
|
devID.bus:= biPCI;
|
||||||
|
devID.id0:= idANY;
|
||||||
|
devID.id1:= $00000001;
|
||||||
|
devID.id2:= $00000006;
|
||||||
|
devID.id3:= $00000001;
|
||||||
|
devID.id4:= idANY;
|
||||||
|
devID.ex:= nil;
|
||||||
|
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;
|
||||||
|
|
||||||
|
procedure load(ptr : void);
|
||||||
|
var
|
||||||
|
device : PPCI_Device;
|
||||||
|
controller : PAHCI_Controller;
|
||||||
|
i : uint32;
|
||||||
|
base : PHBA_Memory;
|
||||||
|
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');
|
||||||
|
// ahciControllers[ahciControllerCount] := ptr;
|
||||||
|
// hba[ahciControllerCount] := PPCI_Device(ptr)^.address5;
|
||||||
|
// new_page_at_address(hba[ahciControllerCount]);
|
||||||
|
|
||||||
|
// //here would be any controller setup needed
|
||||||
|
|
||||||
|
// check_ports(ahciControllerCount);
|
||||||
|
// ahciControllerCount += 1;
|
||||||
|
// exit(true);
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
end.
|
||||||
File diff suppressed because it is too large.
Load diff
+456
-381
File diff suppressed because it is too large.
Load diff
@@ -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
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -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
@@ -0,0 +1,148 @@
|
|||||||
|
// 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; //1FC on some systems, 3F6 on all
|
||||||
|
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;
|
||||||
|
blockSize : uint32;
|
||||||
|
info : PIdentResponse;
|
||||||
|
end;
|
||||||
|
|
||||||
|
TIDE_PACKET = record
|
||||||
|
command : uint8;
|
||||||
|
lba : uint32;
|
||||||
|
count : uint8;
|
||||||
|
buffer : puint16;
|
||||||
|
end;
|
||||||
|
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
end.
|
||||||
File diff suppressed because it is too large.
Load diff
File diff suppressed because it is too large.
Load diff
@@ -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
Loaded 20 of 26 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user