Compare commits
9
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a701db871e | ||
|
|
d0425a41e3 | ||
|
|
463b746b82 | ||
|
|
7d518418c2 | ||
|
|
8b4335768b | ||
|
|
91cd005361 | ||
|
|
99fd5507ca | ||
|
|
035d489c4f | ||
|
|
5e9d0004d7 |
No files matched your search
+1
-1
@@ -14,6 +14,6 @@ localenv.json
|
|||||||
/lvgl/
|
/lvgl/
|
||||||
dockerout.txt
|
dockerout.txt
|
||||||
AGENTS.md
|
AGENTS.md
|
||||||
lessons_learnt.md
|
|
||||||
*.log
|
*.log
|
||||||
/doc/*.md
|
/doc/*.md
|
||||||
|
wasuro
|
||||||
@@ -24,6 +24,7 @@ declare -a run_steps=(
|
|||||||
"compile_stub.sh" "Failed to compile stub!"
|
"compile_stub.sh" "Failed to compile stub!"
|
||||||
"compile_vergen.sh" "Versions failed to compile"
|
"compile_vergen.sh" "Versions failed to compile"
|
||||||
"compile_lvgl.sh" "Failed to compile LVGL!"
|
"compile_lvgl.sh" "Failed to compile LVGL!"
|
||||||
|
"compile_wasuro.sh" "Failed to pull Wasuro!"
|
||||||
"compile_sources.sh" "Failed to compile FPC Sources!"
|
"compile_sources.sh" "Failed to compile FPC Sources!"
|
||||||
"compile_link.sh" "Failed linking!"
|
"compile_link.sh" "Failed linking!"
|
||||||
"compile_isogen.sh" "Failed to create ISO!"
|
"compile_isogen.sh" "Failed to create ISO!"
|
||||||
|
|||||||
+7
-21
@@ -1,7 +1,7 @@
|
|||||||
#!/usr/bin/env bash
|
#!/usr/bin/env bash
|
||||||
# compile_lvgl.sh — Download LVGL v9.2 source and compile into lib/liblvgl.a
|
# compile_lvgl.sh — Download LVGL v9.2 source and compile into lib/liblvgl.a
|
||||||
# Clone & compile in /tmp (fast container-local fs).
|
# Clone & compile in /tmp (fast container-local fs).
|
||||||
# Cache liblvgl.a on host mount (/code/lvgl/) to skip rebuild.
|
# Copy source + objects to /lvgl (host mount) for debugging.
|
||||||
set -e
|
set -e
|
||||||
|
|
||||||
LVGL_VERSION="v9.2.2"
|
LVGL_VERSION="v9.2.2"
|
||||||
@@ -10,7 +10,6 @@ LVGL_DIR="/tmp/lvgl"
|
|||||||
OBJ_DIR="/tmp/lvgl_obj"
|
OBJ_DIR="/tmp/lvgl_obj"
|
||||||
CONF_DIR="$(pwd)/lvglh"
|
CONF_DIR="$(pwd)/lvglh"
|
||||||
OUT_DIR="$(pwd)/lib"
|
OUT_DIR="$(pwd)/lib"
|
||||||
CACHE_DIR="/code/lvgl"
|
|
||||||
|
|
||||||
CC="gcc"
|
CC="gcc"
|
||||||
CFLAGS="-m32 -march=i686 -ffreestanding \
|
CFLAGS="-m32 -march=i686 -ffreestanding \
|
||||||
@@ -27,17 +26,6 @@ echo " "
|
|||||||
echo "Compiling LVGL..."
|
echo "Compiling LVGL..."
|
||||||
echo " "
|
echo " "
|
||||||
|
|
||||||
# If cached liblvgl.a exists on host mount, just copy it and skip everything
|
|
||||||
if [ -f "${CACHE_DIR}/liblvgl.a" ]; then
|
|
||||||
echo "Found cached liblvgl.a in ${CACHE_DIR}, copying to ${OUT_DIR}..."
|
|
||||||
cp "${CACHE_DIR}/liblvgl.a" "${OUT_DIR}/liblvgl.a"
|
|
||||||
echo "(Delete lvgl/liblvgl.a to force a full rebuild.)"
|
|
||||||
echo " "
|
|
||||||
echo "LVGL compilation complete (cached)."
|
|
||||||
echo " "
|
|
||||||
exit 0
|
|
||||||
fi
|
|
||||||
|
|
||||||
# Clone LVGL into /tmp (container-local)
|
# Clone LVGL into /tmp (container-local)
|
||||||
rm -rf "$LVGL_DIR"
|
rm -rf "$LVGL_DIR"
|
||||||
echo "Downloading LVGL ${LVGL_VERSION}..."
|
echo "Downloading LVGL ${LVGL_VERSION}..."
|
||||||
@@ -117,14 +105,12 @@ else
|
|||||||
echo "No custom LVGL files in lvglh/."
|
echo "No custom LVGL files in lvglh/."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Cache liblvgl.a and source to host mount for next build
|
# Copy source + objects to /lvgl host mount for debugging
|
||||||
echo "Caching LVGL to host mount..."
|
echo "Copying LVGL source and objects to host mount..."
|
||||||
mkdir -p "$CACHE_DIR"
|
mkdir /code/lvgl 2>/dev/null || true
|
||||||
rm -rf ${CACHE_DIR}/* ${CACHE_DIR}/.[!.]* ${CACHE_DIR}/..?* 2>/dev/null || true
|
rm -rf /code/lvgl/* /code/lvgl/.[!.]* /code/lvgl/..?* 2>/dev/null || true
|
||||||
cp "${OUT_DIR}/liblvgl.a" "${CACHE_DIR}/liblvgl.a"
|
cp -a "$LVGL_DIR/src" /code/lvgl/src
|
||||||
cp -a "$LVGL_DIR/src" "${CACHE_DIR}/src"
|
cp -a "$OBJ_DIR" /code/lvgl/obj
|
||||||
cp -a "$LVGL_DIR"/*.h "${CACHE_DIR}/" 2>/dev/null || true
|
|
||||||
cp -a "$OBJ_DIR" "${CACHE_DIR}/obj"
|
|
||||||
echo "Done."
|
echo "Done."
|
||||||
|
|
||||||
echo " "
|
echo " "
|
||||||
|
|||||||
+2
-1
@@ -4,10 +4,11 @@ echo "======================="
|
|||||||
echo " "
|
echo " "
|
||||||
echo "Compiling FPC Sources..."
|
echo "Compiling FPC Sources..."
|
||||||
echo " "
|
echo " "
|
||||||
|
|
||||||
# Build -Fu flags for all directories under src/ and wasuro/
|
# Build -Fu flags for all directories under src/ and wasuro/
|
||||||
FU_PATHS="-Fusrc -Fuwasuro"
|
FU_PATHS="-Fusrc -Fuwasuro"
|
||||||
for dir in $(find src wasuro -type d 2>/dev/null); do
|
for dir in $(find src wasuro -type d 2>/dev/null); do
|
||||||
FU_PATHS="$FU_PATHS -Fu$dir"
|
FU_PATHS="$FU_PATHS -Fu$dir"
|
||||||
done
|
done
|
||||||
|
|
||||||
fpc -Aelf -gw -g -gl -n -v0e -O3 -OpPENTIUM3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ $FU_PATHS src/kernel.pas
|
fpc -Aelf -gw -g -gl -n -v0ew -O3 -OpPENTIUM3 -Si -Sc -Sg -Xd -CX -XXs -CfSSE -CfSSE2 -Rintel -Pi386 -Tlinux -FElib/ $FU_PATHS src/kernel.pas
|
||||||
@@ -5,4 +5,3 @@ echo " "
|
|||||||
echo "Compiling Stub..."
|
echo "Compiling Stub..."
|
||||||
echo " "
|
echo " "
|
||||||
nasm -f elf src/stub/stub.asm -o lib/stub.o
|
nasm -f elf src/stub/stub.asm -o lib/stub.o
|
||||||
nasm -f elf src/stub/splash_tga.asm -o lib/splash_tga.o
|
|
||||||
@@ -0,0 +1,43 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# compile_wasuro.sh — Pull Wasuro WASM runtime source into wasuro/
|
||||||
|
# Clones the repo (sparse, src/wasm only) and copies the Pascal sources
|
||||||
|
# into $PWD/wasuro so the FPC build can reference them via -Fu.
|
||||||
|
set -e
|
||||||
|
|
||||||
|
WASURO_REPO="https://gitea.spexeah.com/Spexeah/Wasuro.git"
|
||||||
|
WASURO_BRANCH="develop"
|
||||||
|
WASURO_TMP="/tmp/wasuro"
|
||||||
|
WASURO_OUT="$(pwd)/wasuro"
|
||||||
|
|
||||||
|
echo " "
|
||||||
|
echo "======================="
|
||||||
|
echo " "
|
||||||
|
echo "Pulling Wasuro WASM runtime..."
|
||||||
|
echo " "
|
||||||
|
|
||||||
|
# Skip if wasuro/ already has .pas files (cached from previous build)
|
||||||
|
if [ -n "$(find "${WASURO_OUT}" -name '*.pas' 2>/dev/null | head -1)" ]; then
|
||||||
|
echo "Wasuro sources already present in ${WASURO_OUT}, skipping pull."
|
||||||
|
echo " "
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Clone sparse checkout (only src/wasm)
|
||||||
|
rm -rf "$WASURO_TMP"
|
||||||
|
git clone --depth 1 --branch "${WASURO_BRANCH}" --filter=blob:none --sparse \
|
||||||
|
"${WASURO_REPO}" "${WASURO_TMP}" 2>&1
|
||||||
|
cd "$WASURO_TMP"
|
||||||
|
git sparse-checkout set src/wasm 2>&1
|
||||||
|
cd -
|
||||||
|
|
||||||
|
echo "Copying src/wasm to ${WASURO_OUT}..."
|
||||||
|
rm -rf "$WASURO_OUT"
|
||||||
|
mkdir -p "$WASURO_OUT"
|
||||||
|
cp -a "${WASURO_TMP}/src/wasm/"* "$WASURO_OUT"/
|
||||||
|
rm -rf "$WASURO_TMP"
|
||||||
|
|
||||||
|
TOTAL=$(find "$WASURO_OUT" -name '*.pas' | wc -l)
|
||||||
|
echo "Copied ${TOTAL} Pascal source files."
|
||||||
|
echo " "
|
||||||
|
echo "Wasuro pull complete."
|
||||||
|
echo " "
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
#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
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Binary file not shown.
|
Before Width: | Height: | Size: 1.0 MiB |
Generated
-1
@@ -1 +0,0 @@
|
|||||||
Hello from the Asuro ISO!
|
|
||||||
@@ -29,11 +29,14 @@ unit contextswitcher;
|
|||||||
interface
|
interface
|
||||||
|
|
||||||
uses
|
uses
|
||||||
idt, isrmanager, processmanager, proctypes, util, tracer;
|
idt, isrmanager, processmanager, proctypes, util, syslog, tracer;
|
||||||
|
|
||||||
{ Initialise: overwrite IDT gate 32 with our custom ISR. }
|
{ Initialise: overwrite IDT gate 32 with our custom ISR. }
|
||||||
procedure init;
|
procedure init;
|
||||||
|
|
||||||
|
{ No idle ESP variable needed — idle is now a formal process (PID 0)
|
||||||
|
with its SavedESP managed like any other process. }
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
{ -----------------------------------------------------------------------
|
{ -----------------------------------------------------------------------
|
||||||
|
|||||||
@@ -91,7 +91,6 @@ function getDeviceInfo(class_code : uint8; subclass_code : uint8; prog_if : uint
|
|||||||
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
procedure requestConfig(bus : uint8; slot : uint8; func : uint8; row : uint8);
|
||||||
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
|
procedure writeConfig(bus: uint8; slot : uint8; func : uint8; row : uint8; val : uint32);
|
||||||
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
procedure setBusMaster(bus : uint8; slot : uint8; func : uint8; master : boolean);
|
||||||
procedure enableDevice(bus : uint8; slot : uint8; func : uint8);
|
|
||||||
|
|
||||||
implementation
|
implementation
|
||||||
|
|
||||||
@@ -443,34 +442,4 @@ begin
|
|||||||
pop_trace;
|
pop_trace;
|
||||||
end;
|
end;
|
||||||
|
|
||||||
//Enable device inturrupts and set bus master
|
|
||||||
procedure enableDevice(bus : uint8; slot : uint8; func : uint8);
|
|
||||||
var
|
|
||||||
addr : uint32;
|
|
||||||
cmd : uint32;
|
|
||||||
begin
|
|
||||||
push_trace('PCI.enableDevice');
|
|
||||||
|
|
||||||
addr := ($1 shl 31);
|
|
||||||
addr := addr or (bus shl 16);
|
|
||||||
addr := addr or ((slot) shl 11);
|
|
||||||
addr := addr or ((func) shl 8);
|
|
||||||
addr := addr or ($04 and $FC);
|
|
||||||
|
|
||||||
outl(PCI_CONFIG_ADDRESS_PORT, addr);
|
|
||||||
cmd := inl(PCI_CONFIG_DATA_PORT);
|
|
||||||
cmd := cmd or PCI_COMMAND_MEM_SPACE;
|
|
||||||
cmd := cmd or PCI_COMMAND_BUS_MASTER;
|
|
||||||
cmd := cmd or (3 shl 1);
|
|
||||||
|
|
||||||
//enable interrupts, remove disable interrupt bit maybe
|
|
||||||
cmd := cmd and not PCI_COMMAND_INT_DISABLE;
|
|
||||||
// cmd := cmd and not (1 shl 9);
|
|
||||||
|
|
||||||
outl(PCI_CONFIG_ADDRESS_PORT, addr);
|
|
||||||
outl(PCI_CONFIG_DATA_PORT, cmd);
|
|
||||||
|
|
||||||
pop_trace;
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
end.
|
||||||
@@ -957,14 +957,11 @@ end;
|
|||||||
procedure usb_check_hotplug;
|
procedure usb_check_hotplug;
|
||||||
var
|
var
|
||||||
i : uint32;
|
i : uint32;
|
||||||
count: uint32;
|
|
||||||
hc : PUSBHCDriver;
|
hc : PUSBHCDriver;
|
||||||
port : uint8;
|
port : uint8;
|
||||||
begin
|
begin
|
||||||
if HCList = nil then exit;
|
if HCList = nil then exit;
|
||||||
count := LL_Size(HCList);
|
for i := 0 to LL_Size(HCList) - 1 do begin
|
||||||
if count = 0 then exit;
|
|
||||||
for i := 0 to count - 1 do begin
|
|
||||||
hc := PUSBHCDriver(LL_Get(HCList, i));
|
hc := PUSBHCDriver(LL_Get(HCList, i));
|
||||||
if (hc <> nil) and hc^.PortChangePending then begin
|
if (hc <> nil) and hc^.PortChangePending then begin
|
||||||
hc^.PortChangePending := false;
|
hc^.PortChangePending := false;
|
||||||
|
|||||||
@@ -119,12 +119,8 @@ var
|
|||||||
x32, y32 : sint32;
|
x32, y32 : sint32;
|
||||||
r : pchar;
|
r : pchar;
|
||||||
begin
|
begin
|
||||||
{ mouse_wait(0) checks OBF with a short timeout (100 iterations).
|
|
||||||
When it returns true, data is ready — read it directly with inb($60).
|
|
||||||
Do NOT call mouse_read here: it uses mouse_wait_long (100k iterations)
|
|
||||||
and would spin-block the ISR if the next packet byte hasn't arrived yet. }
|
|
||||||
while mouse_wait(0) do begin
|
while mouse_wait(0) do begin
|
||||||
b := inb($60);
|
b := mouse_read;
|
||||||
if Cycle = 0 then begin
|
if Cycle = 0 then begin
|
||||||
if (b AND $08) = $08 then begin
|
if (b AND $08) = $08 then begin
|
||||||
Mouse_Byte[Cycle] := b;
|
Mouse_Byte[Cycle] := b;
|
||||||
|
|||||||
@@ -21,29 +21,6 @@ unit drivertypes;
|
|||||||
|
|
||||||
interface
|
interface
|
||||||
|
|
||||||
const
|
|
||||||
PCI_CONFIG_ADDRESS_PORT = $0CF8;
|
|
||||||
PCI_CONFIG_DATA_PORT = $0CFC;
|
|
||||||
|
|
||||||
PCI_COMMAND_IO_SPACE = $0001;
|
|
||||||
PCI_COMMAND_MEM_SPACE = $0002;
|
|
||||||
PCI_COMMAND_BUS_MASTER = $0004;
|
|
||||||
PCI_COMMAND_SPECIAL_CYC = $0008;
|
|
||||||
PCI_COMMAND_MEM_WRITE = $0010;
|
|
||||||
PCI_COMMAND_VGA_PALETTE = $0020;
|
|
||||||
PCI_COMMAND_PARITY = $0040;
|
|
||||||
PCI_COMMAND_WAIT = $0080;
|
|
||||||
PCI_COMMAND_SERR = $0100;
|
|
||||||
PCI_COMMAND_FAST_BACK = $0200;
|
|
||||||
PCI_COMMAND_INT_DISABLE = $0400;
|
|
||||||
PCI_COMMAND_SERR_ENABLE = $8000;
|
|
||||||
|
|
||||||
PCI_CAP_ID_MSI = $05;
|
|
||||||
|
|
||||||
// Bits in the MSI Control register (16-bit):
|
|
||||||
MSI_CONTROL_ENABLE = 1 shl 0; // Bit 0
|
|
||||||
MSI_CONTROL_64BIT = 1 shl 7; // Bit 7
|
|
||||||
MSI_CONTROL_PVMASK = 1 shl 8; // Bit 8 (optional: per-vector masking)
|
|
||||||
type
|
type
|
||||||
|
|
||||||
PPCI_Device = ^TPCI_Device;
|
PPCI_Device = ^TPCI_Device;
|
||||||
@@ -67,7 +44,6 @@ type
|
|||||||
address1 : uint32;
|
address1 : uint32;
|
||||||
address2 : uint32;
|
address2 : uint32;
|
||||||
address3 : uint32;
|
address3 : uint32;
|
||||||
|
|
||||||
address4 : uint32;
|
address4 : uint32;
|
||||||
address5 : uint32;
|
address5 : uint32;
|
||||||
CIS_pointer : uint32;
|
CIS_pointer : uint32;
|
||||||
|
|||||||
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
@@ -0,0 +1,85 @@
|
|||||||
|
// 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_ISR - Primary ATA IRQ.
|
||||||
|
|
||||||
|
@author(Aaron Hance <[email protected]>)
|
||||||
|
}
|
||||||
|
unit ATA_ISR;
|
||||||
|
|
||||||
|
interface
|
||||||
|
|
||||||
|
uses
|
||||||
|
util,
|
||||||
|
syslog,
|
||||||
|
isr_types,
|
||||||
|
isrmanager,
|
||||||
|
IDT;
|
||||||
|
|
||||||
|
procedure register();
|
||||||
|
procedure hook(hook_method : uint32);
|
||||||
|
procedure unhook(hook_method : uint32);
|
||||||
|
|
||||||
|
implementation
|
||||||
|
|
||||||
|
var
|
||||||
|
Hooks : Array[1..MAX_HOOKS] of pp_hook_method;
|
||||||
|
|
||||||
|
procedure Main(); interrupt;
|
||||||
|
var
|
||||||
|
i : integer;
|
||||||
|
|
||||||
|
begin
|
||||||
|
CLI;
|
||||||
|
for i:=0 to MAX_HOOKS-1 do begin
|
||||||
|
if uint32(Hooks[i]) <> 0 then Hooks[i](void($00000000));
|
||||||
|
end;
|
||||||
|
syslog.writestringln('Disk Operation Complete');
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure register();
|
||||||
|
begin
|
||||||
|
memset(uint32(@Hooks[0]), 0, sizeof(pp_hook_method)*MAX_HOOKS);
|
||||||
|
//isrmanager.registerISR(76, @Main);
|
||||||
|
//IDT.set_gate(76, uint32(@Main), $08, ISR_RING_0);
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure hook(hook_method : uint32);
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
|
||||||
|
begin
|
||||||
|
for i:=0 to MAX_HOOKS-1 do begin
|
||||||
|
if uint32(Hooks[i]) = hook_method then exit;
|
||||||
|
end;
|
||||||
|
for i:=0 to MAX_HOOKS-1 do begin
|
||||||
|
if uint32(Hooks[i]) = 0 then begin
|
||||||
|
Hooks[i]:= pp_hook_method(hook_method);
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
procedure unhook(hook_method : uint32);
|
||||||
|
var
|
||||||
|
i : uint32;
|
||||||
|
begin
|
||||||
|
for i:=0 to MAX_HOOKS-1 do begin
|
||||||
|
If uint32(Hooks[i]) = hook_method then Hooks[i]:= nil;
|
||||||
|
exit;
|
||||||
|
end;
|
||||||
|
end;
|
||||||
|
|
||||||
|
end.
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -1,120 +0,0 @@
|
|||||||
{
|
|
||||||
Driver->Storage->FilesystemManager - Filesystem driver registry and routing.
|
|
||||||
|
|
||||||
Filesystem drivers (FAT32, FlatFS, etc.) register themselves here.
|
|
||||||
When VolumeManager discovers a volume, FilesystemManager probes it
|
|
||||||
against all registered filesystem drivers to detect the filesystem type.
|
|
||||||
|
|
||||||
@author(Aaron Hance <[email protected]>)
|
|
||||||
}
|
|
||||||
unit filesystemmanager;
|
|
||||||
|
|
||||||
interface
|
|
||||||
|
|
||||||
uses
|
|
||||||
lists,
|
|
||||||
lmemorymanager,
|
|
||||||
storagetypes,
|
|
||||||
strings,
|
|
||||||
tracer,
|
|
||||||
util;
|
|
||||||
|
|
||||||
var
|
|
||||||
filesystems : PLinkedListBase;
|
|
||||||
|
|
||||||
procedure init();
|
|
||||||
procedure register_filesystem(filesystem : PFilesystem);
|
|
||||||
function get_filesystem_count() : uint32;
|
|
||||||
function get_filesystem(index : uint32) : PFilesystem;
|
|
||||||
function find_filesystem_by_name(name : pchar) : PFilesystem;
|
|
||||||
function find_filesystem_by_id(system_id : uint8) : PFilesystem;
|
|
||||||
procedure probe_volume(volume : PStorage_Volume);
|
|
||||||
|
|
||||||
implementation
|
|
||||||
|
|
||||||
procedure init();
|
|
||||||
begin
|
|
||||||
push_trace('FilesystemManager.init');
|
|
||||||
filesystems := LL_New(sizeof(TFilesystem));
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure register_filesystem(filesystem : PFilesystem);
|
|
||||||
var
|
|
||||||
elm : void;
|
|
||||||
begin
|
|
||||||
push_trace('FilesystemManager.register_filesystem');
|
|
||||||
|
|
||||||
elm := LL_Add(filesystems);
|
|
||||||
memcpy(uint32(filesystem), uint32(elm), sizeof(TFilesystem));
|
|
||||||
end;
|
|
||||||
|
|
||||||
function get_filesystem_count() : uint32;
|
|
||||||
begin
|
|
||||||
get_filesystem_count := LL_Size(filesystems);
|
|
||||||
end;
|
|
||||||
|
|
||||||
function get_filesystem(index : uint32) : PFilesystem;
|
|
||||||
begin
|
|
||||||
if index < LL_Size(filesystems) then
|
|
||||||
get_filesystem := PFilesystem(LL_Get(filesystems, index))
|
|
||||||
else
|
|
||||||
get_filesystem := nil;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function find_filesystem_by_name(name : pchar) : PFilesystem;
|
|
||||||
var
|
|
||||||
i : uint32;
|
|
||||||
fs : PFilesystem;
|
|
||||||
begin
|
|
||||||
push_trace('FilesystemManager.find_filesystem_by_name');
|
|
||||||
find_filesystem_by_name := nil;
|
|
||||||
|
|
||||||
for i := 0 to LL_Size(filesystems) - 1 do begin
|
|
||||||
fs := PFilesystem(LL_Get(filesystems, i));
|
|
||||||
if stringEquals(fs^.sName, name) then begin
|
|
||||||
find_filesystem_by_name := fs;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
function find_filesystem_by_id(system_id : uint8) : PFilesystem;
|
|
||||||
var
|
|
||||||
i : uint32;
|
|
||||||
fs : PFilesystem;
|
|
||||||
begin
|
|
||||||
push_trace('FilesystemManager.find_filesystem_by_id');
|
|
||||||
find_filesystem_by_id := nil;
|
|
||||||
|
|
||||||
for i := 0 to LL_Size(filesystems) - 1 do begin
|
|
||||||
fs := PFilesystem(LL_Get(filesystems, i));
|
|
||||||
if fs^.system_id = system_id then begin
|
|
||||||
find_filesystem_by_id := fs;
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
|
|
||||||
procedure probe_volume(volume : PStorage_Volume);
|
|
||||||
var
|
|
||||||
i : uint32;
|
|
||||||
fs : PFilesystem;
|
|
||||||
begin
|
|
||||||
push_trace('FilesystemManager.probe_volume.enter');
|
|
||||||
|
|
||||||
{ Try each registered filesystem's identify callback against this volume }
|
|
||||||
for i := 0 to LL_Size(filesystems) - 1 do begin
|
|
||||||
fs := PFilesystem(LL_Get(filesystems, i));
|
|
||||||
if fs^.identifyCallback <> nil then begin
|
|
||||||
push_trace('FilesystemManager.probe_volume.tryFS');
|
|
||||||
if fs^.identifyCallback(volume) then begin
|
|
||||||
volume^.filesystem := fs;
|
|
||||||
push_trace('FilesystemManager.probe_volume.found');
|
|
||||||
exit;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
end;
|
|
||||||
push_trace('FilesystemManager.probe_volume.exit');
|
|
||||||
end;
|
|
||||||
|
|
||||||
end.
|
|
||||||
Loaded 20 of 99 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user